-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcloud-control-bot.service
More file actions
39 lines (33 loc) · 1.41 KB
/
Copy pathcloud-control-bot.service
File metadata and controls
39 lines (33 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# systemd unit for running cloud-control-bot 24/7 without Docker.
#
# Install (adjust paths/user to your deployment):
# sudo useradd --system --create-home --home-dir /opt/cloud-control-bot cpm
# # deploy the code to /opt/cloud-control-bot, create the venv and .env there
# sudo cp deploy/cloud-control-bot.service /etc/systemd/system/
# sudo systemctl daemon-reload
# sudo systemctl enable --now cloud-control-bot
# journalctl -u cloud-control-bot -f # follow logs
[Unit]
Description=cloud-control-bot Telegram bot
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=cpm
WorkingDirectory=/opt/cloud-control-bot
EnvironmentFile=/opt/cloud-control-bot/.env
ExecStart=/opt/cloud-control-bot/venv/bin/python main.py
# Restart the PROCESS on crash. The in-app supervisor only restarts background
# tasks, not main.py itself, so this is what keeps the bot alive after a hard crash.
Restart=on-failure
RestartSec=10
# Grant raw-socket capability for ICMP ping without running as root. This is the
# clean, deployment-scoped alternative to `setcap` on the python binary (which an
# unrelated pip upgrade would silently invalidate).
AmbientCapabilities=CAP_NET_RAW
CapabilityBoundingSet=CAP_NET_RAW
# Hardening: prevent the service from gaining new privileges (e.g. via a setuid
# binary), so the capability restriction above cannot be escaped.
NoNewPrivileges=yes
[Install]
WantedBy=multi-user.target