conso.sh docs
Run a persistent worker
Keep a process running with Docker Compose or systemd.
Docker Compose
Install Docker and the Compose plugin using the instructions for your Linux distribution. On the VM, open your own project with a Compose file. Replace <project-dir> and <service> with the path and service name. Configure persistent volumes for data and a restart policy such as restart: unless-stopped when the workload should return after a reboot.
cd <project-dir>
docker compose up -d
docker compose ps
docker compose logs --tail=100 <service>systemd
On a systemd-based guest, create a dedicated unprivileged user named worker first. Replace the sample paths with the directory and executable for your application. Save the unit as /etc/systemd/system/worker.service. Make sure the worker user can read the application and write only where needed.
[Unit]
Description=Project worker
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
User=worker
WorkingDirectory=/opt/worker
ExecStart=/opt/worker/bin/run
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetsudo systemctl daemon-reload
sudo systemctl enable --now worker.service
systemctl status worker.service
sudo journalctl -u worker.service -n 100Provide application credentials using your chosen secret mechanism. Check that the application does useful work after disconnecting and after a planned restart.