cogos serve command supports subcommands for daemon lifecycle management, log viewing, and boot auto-start.
Running modes
- Foreground
- Background daemon
- Daemon + auto-start
Run the server in the current terminal session. Stops when you press Ctrl+C or close the terminal.
Port configuration
The server port can be specified in two ways (highest priority wins):- Command-line flag:
cogos serve --port 9000 start - Config file:
server.portinconfigs/cogos.yaml - Default:
8000
--port flag is defined on the serve group, so it works with all subcommands and foreground mode.
Daemon management
Start
--host, --port, and --template are defined on the parent serve command and apply to all subcommands. Pass --autostart to also enable boot auto-start via systemd.
Stop
--remove-autostart to also disable the systemd auto-start service.
Restart
Status
- Running state and PID
- Log file location
- Uptime, memory usage, and CPU (when
psutilis installed) - Whether auto-start is enabled
Install
psutil (pip install psutil) for uptime, memory, and CPU metrics in the status output.Boot auto-start
Use the--autostart flag on start to register a systemd user service:
- Starts the daemon immediately
- Generates a systemd unit file at
~/.config/systemd/user/cogos.service - Enables the service with
systemctl --user enable cogos - Runs
loginctl enable-lingerso the service survives user logout
Manual systemd control
After enabling auto-start, you can also manage the service directly with systemctl:Log management
View recent server output:~/.cogos/cogos.log
File locations
| File | Purpose |
|---|---|
~/.cogos/cogos.pid | PID of the running daemon process |
~/.cogos/cogos.log | Server stdout and stderr output |
~/.config/systemd/user/cogos.service | Systemd unit file (created by --autostart) |
Command reference
| Command | Description |
|---|---|
cogos serve | Start in foreground (Ctrl+C to stop) |
cogos serve start | Start as background daemon |
cogos serve start --autostart | Start daemon + enable boot auto-start (systemd) |
cogos serve stop | Stop the daemon |
cogos serve stop --remove-autostart | Stop daemon + disable boot auto-start |
cogos serve restart | Restart the daemon |
cogos serve status | Show status, PID, uptime, memory, auto-start state |
cogos serve logs | View logs (-f follow, -n line count) |