trivial unit files fur systemd
@MindmeshLink the trivial systemd script fur daemons that are Just A Purrocess You Simply Run From The Command Line is
$ cat /etc/systemd/system/my-unit-name.service
[Unit]
Description=name of this service
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
ExecStart=[command line here (you can use spaces)]
# the following make systemd automatically re-up the service every time it downs, which is usually desirable behavior
Restart=always
RestartSec=1 # you usually want some throttling in case it keeps exiting immediately
then run systemctl daemon-reload
, and then systemctl enable my-unit-name.service
(.service
is optional). use systemctl status my-unit-name.service
if you want confurmation that it worked fine.
standard output and error should automatically get logged to the systemd journal; you can view that output with journalctl -u my-unit-name.service
useful extra things re: trivial unit files fur systemd
WorkingDirectory=/path/to/desired/working/directory
; if your script picks up configs from the current directory this will make setup simplerUser=username
, in the same sectionEnvironment="ENV_VAR=whatever"
lines as required under that same sectionEnvironmentFile=/path/to/file
; the syntax is in VAR="contents"
furmat)unsolicited suggestion re: useful extra things re: trivial unit files fur systemd
@MindmeshLink an arguable cheat is ExecStart=fish -c "[whatever the venv command is, i furget]; exec [final command]
. i think that should work