45 lines
791 B
Markdown
45 lines
791 B
Markdown
1. Open new service file:
|
|
```
|
|
sudo nano /etc/systemd/system/<name>.service
|
|
```
|
|
|
|
2. Content
|
|
```
|
|
[Unit]
|
|
Description=Page Host Service
|
|
After=network.target
|
|
|
|
[Service]
|
|
User=your_username
|
|
WorkingDirectory=/home/your_username/repo/asobi
|
|
Environment=PYENV_ROOT=/home/your_username/.pyenv
|
|
ExecStart=/bin/bash -c "source $PYENV_ROOT/bin/pyenv && pyenv activate pyenv && python page_host.py"
|
|
Restart=always
|
|
RestartSec=5
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
3. Reload systemd, enable service:
|
|
```
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl enable <name>.service
|
|
sudo systemctl start <name>.service
|
|
```
|
|
|
|
4. Check status:
|
|
```
|
|
sudo systemctl status <name>.service
|
|
journalctl -u <name>.service
|
|
```
|
|
|
|
5. Test reboot:
|
|
```
|
|
sudo reboot
|
|
```
|
|
|
|
Check status
|
|
```
|
|
sudo systemctl status page_host.service
|
|
``` |