Dealing with Server Commands

Guide on managing multiple Hugo server processes on a single machine including finding, understanding, and terminating active jobs to prevent conflicts and ensure smooth operation of HBStack-powered sites.

This document provides the information about running and managing Hugo server

๐Ÿงฉ Managing Multiple Site Processes on a Single Machine

When running multiple Hugo sites or similar services on one machine, it’s essential to monitor and manage active processes to avoid port conflicts, memory leaks, or zombie jobs.


๐Ÿ” Finding Running Jobs

Use ps and grep to locate processes:

1ps aux | grep hugo | grep -v grep

This lists all Hugo-related processes. Example output:

1user     12345  0.0  1.2 123456 7890 pts/0   S   12:34   0:01 hugo server --port 3300
  • PID: Process ID (e.g. 12345)
  • Command: What was launched
  • Status: S (sleeping), R (running), T (stopped), Z (zombie)

๐Ÿง  Understanding Process States

CodeMeaningAction Needed
RRunningNormal
SSleepingNormal
TStoppedResume or kill
ZZombie (<defunct>)Kill parent to clean up

๐Ÿ”ช Killing a Process

To terminate a process:

1kill <PID>

If it doesn’t respond:

1kill -9 <PID>

For zombie processes:

  1. Identify the parent PID (usually a shell like sh -c)
  2. Kill the parent:
1kill -9 <PARENT_PID>

๐Ÿงผ Cleanup Script (Optional)

1ps aux | grep hugo | grep -v grep | awk '{print $2}' | xargs kill -9

Use with caution โ€” this forcefully kills all Hugo-related jobs.


โœ… Best Practices

  • Use unique ports for each site (--port 3300, --port 3400, etc.)
  • Log process launches for traceability
  • Consider wrapping launches in Makefile targets or shell scripts

FAQs