33 lines
660 B
Markdown
33 lines
660 B
Markdown
# Create a Systemd Service File
|
|
1. Create a Service File:
|
|
- Create a new service file to manage page_host.py:
|
|
```bash
|
|
sudo nano /etc/systemd/system/page_host.service
|
|
```
|
|
|
|
2. Add the following configuration to manage the script:
|
|
```bash
|
|
[Unit]
|
|
Description=Python page_host Service
|
|
After=network.target
|
|
|
|
[Service]
|
|
WorkingDirectory=/home/git/deployed-repo # Directory containing page_host.py
|
|
ExecStart=/usr/bin/python3 /home/git/deployed-repo/page_host.py
|
|
Restart=always
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|
|
```
|
|
|
|
3. Enable the service to start at boot:
|
|
```bash
|
|
sudo systemctl enable page_host
|
|
```
|
|
|
|
Start the service:
|
|
```bash
|
|
sudo systemctl start page_host
|
|
```
|
|
|