Around Go: command line · 3 MIN READ
A Go service on Linux: systemctl and journalctl
Inspect a systemd service, follow its logs and understand its restart boundary.
A native Go binary can run directly under a service manager; Kubernetes is not required. These examples assume Linux with systemd and a preinstalled go-api.service. They do not apply to macOS launchd or every container environment.
Read the unit and its current state
systemctl cat shows the installed unit and drop-ins. status includes active state and recent log context; show exposes selected properties. Verify the executable and service user before changing the process lifecycle.
systemctl cat go-api.service
systemctl status go-api.service --no-pager
systemctl show go-api.service -p MainPID -p ActiveState -p SubStateAn inactive or failed status can produce a nonzero exit code. Check ExecStart, WorkingDirectory and User in the unit. Unit content may reveal configuration paths; inspect only the required evidence before sharing logs.
Follow the unit log instead of guessing a file path
journalctl selects journal entries for a unit and time range. -f follows new entries; Ctrl-C stops following without stopping the service. Access may require membership or administrator permissions depending on the host configuration.
journalctl -u go-api.service --since "10 minutes ago" --no-pager
journalctl -u go-api.service -n 50 --no-pager
journalctl -u go-api.service -fCorrelate startup, request errors and shutdown timestamps. A missing journal permission is different from no application logs. The program should emit useful stdout/stderr records without credentials or full sensitive request payloads.
Restart the intended service and verify recovery
daemon-reload reloads unit definitions after editing them; it does not restart a process by itself. restart replaces the running service and can interrupt traffic. An ordinary deployment needs a deliberate change window and an application shutdown budget.
# After an intentional unit-file change on your own host:
sudo systemctl daemon-reload
sudo systemctl restart go-api.service
systemctl is-active go-api.service
curl --max-time 5 --fail-with-body http://127.0.0.1:8080/healthzThese two sudo commands mutate host state and need authorization on that machine. Verify both service state and HTTP behavior. A running process can still be unhealthy; repeated restarts can conceal a bad configuration instead of repairing it.
TAKE THIS WITH YOU
Inspect the unit, state and journal before restarting. Reloading definitions and replacing a process are distinct actions; verify the application endpoint after a controlled service change.
Check your understanding
What does systemctl daemon-reload do?
Go to the source
Progress stays in this browser. No account needed.