Services
Services
A service is a program the machine keeps running: started at every boot (also after a suspend, which is a reboot), restarted when it exits, with its output in a log file. Use it for anything that should outlive your SSH session or your agent’s turn: a dev server, a worker, the agent itself.
space-env services create notes --restart on-failure -- sh -c "while sleep 60; do date; done"
space-env services list
space-env services logs notes --lines 20
space-env services stop notes
space-env services start notes
space-env services delete notes--restart:always(the default),on-failure(only after a non-zero exit) ornever. Restarts back off from 1 to 30 seconds.stopis sticky: the service stays stopped, also after a reboot, untilstart.- Stopping is a SIGTERM to the service’s program, then up to 10 seconds to end, then a SIGKILL. A suspend stops every service this way before the machine powers off, so a program that writes its state when asked to stop (a database, a browser) has it on disk.
--needs otherstartsotherfirst at boot.--env KEY=VALUEand--cwd DIRset its environment and working directory.- Logs are in
/var/log/space-env/<name>.log, rotated at 10 MiB;tail -ffollows one. - A service that dies (a non-zero exit or a signal, not a
stop) is reported as a machine event, which owners and admins see in the portal’s Audit log (when the agent dies). - A definition with
"on_demand": trueisn’t started at boot: it waits for its firststart, and after a reboot waits again. The agent’s browser is one. - Services are handled by the machine itself, so they work without the platform being
reachable. Definitions are files in
/etc/vmagent/services.d/(one JSON file each), and editing those by hand takes effect at the next boot.
Don’t start long-lived programs in the background of a shell (nohup … &) instead: they
die with the shell or the next suspend, and nothing restarts them. The guide
a service that survives a suspend shows the whole setup.
Last updated on