ガイド · VPS
プログラムを動かし続ける
systemd サービスを1つ作れば再起動しても起動します。
1. Apps selected with your order
/root/apps has a start.sh in each app directory (Desktop folder on desktop editions).
| App | Directory | Startup unit |
|---|---|---|
| Minecraft server (Paper) | minecraft | minecraft |
| Web server (Caddy) | web | web (started during installation) |
| Discord bot (Python) | discord-bot | discord-bot |
| Node.js app | node-app | node-app |
| Action | Command (in that directory) |
|---|---|
| Run in the current session | ./start.sh |
| Enable at boot + start now | ./start.sh --service |
| Disable automatic startup | ./start.sh --remove-service |
2. Run your program as a service
Example: /root/mybot/main.py. nano /etc/systemd/system/mybot.service:
[Unit]
Description=My bot
After=network-online.target
Wants=network-online.target
[Service]
WorkingDirectory=/root/mybot
ExecStart=/root/mybot/venv/bin/python main.py
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
| Action | Command |
|---|---|
| Enable · start | systemctl daemon-reload && systemctl enable --now mybot |
| Status | systemctl status mybot |
| Logs (live) | journalctl -u mybot -f |
| Restart (after editing code) | systemctl restart mybot |
| Stop · disable at boot | systemctl disable --now mybot |
Restart=always = restart 5 seconds after exit. After editing the service file, run daemon-reload first.
3. Python venv
apt install -y python3-venv
cd /root/mybot
python3 -m venv venv
venv/bin/pip install -r requirements.txt
Ubuntu 24.04 and Debian 12 or newer restrict system pip installs; use a venv.
4. Node.js
- Node path:
which node→ use that path inExecStart(e.g.ExecStart=/usr/bin/node index.js). - Values such as tokens: under
[Service], addEnvironmentFile=/root/mybot/.env.
5. Temporary sessions (tmux)
apt install -y tmux→tmux new -s work→ run your program.- Press Ctrl+B then D → it keeps running after you close the window.
- Reattach:
tmux attach -t work.
tmux and screen sessions do not survive a server reboot. Use systemd for persistent programs.