Using systemd

Here are the systemd files that can be used to deploy the server and the agents.

Agent

/etc/systemd/system/argos-agent.service
[Unit]
Description=Argos agent
Documentation=https://framasoft.frama.io/framaspace/argos/
Requires=network.target
After=network.target

[Service]
User=www-data
Environment="ARGOS_AGENT_TOKEN=Secret"
Environment="ARGOS_AGENT_SERVER_URL=http://127.0.0.1:8000"
WorkingDirectory=/var/www/argos/
ExecStart=/var/www/argos/venv/bin/argos agent --max-tasks 20 --wait-time 10 --log-level DEBUG
SyslogIdentifier=argos-agent

[Install]
WantedBy=multi-user.target

# NB: it may be better to
# - use a dedicated user
# - use a EnvironmentFile=/etc/default/argos-agent in order to enable configuration
#   changes without doing a systemctl daemon-reload

Server

/etc/systemd/system/argos-server.service
[Unit]
Description=Argos server
Documentation=https://framasoft.frama.io/framaspace/argos/
Requires=network.target postgresql.service
After=network.target postgresql.service
PartOf=postgresql.service

[Service]
User=www-data
WorkingDirectory=/var/www/argos/
Environment="ARGOS_SERVER_WORKERS=4"
Environment="ARGOS_SERVER_SOCKET=127.0.0.1:8000"
ExecStartPre=/var/www/argos/venv/bin/argos server migrate
ExecStartPre=/var/www/argos/venv/bin/argos server reload-config
ExecStart=/var/www/argos/venv/bin/gunicorn "argos.server.main:get_application()" -w $ARGOS_SERVER_WORKERS -k uvicorn.workers.UvicornWorker -b $ARGOS_SERVER_SOCKET
ExecReload=/var/www/argos/venv/bin/argos server reload
SyslogIdentifier=argos-server

[Install]
WantedBy=multi-user.target

# NB: it may be better to
# - use a EnvironmentFile=/etc/default/argos-server in order to enable configuration
#   changes without doing a systemctl daemon-reload