如何使用 systemd 服务 运行 pygame 脚本?
How to Run pygame script using systemd service?
我想 运行 pygame 使用 systemd 服务的脚本
按照这些步骤 运行 使用 systemd 服务的 pygame 脚本
sudo systemctl daemon-reload
sudo systemctl enable service_name
sudo systemctl start service_name
并在我的服务不想 运行 一个 pygame 脚本来获得更多理解后重新启动系统
$ sudo journalctl -f -u rpi
-- Logs begin at Thu 2016-11-03 22:46:42 IST. --
Mar 28 12:19:11 raspberrypi systemd[1]: Started RPi-Service.
$sudo systemctl status rpi
rpi.service - RPi-Service
Loaded: loaded (/lib/systemd/system/rpi.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Thu 2019-03-28 12:19:14 IST; 22min ago
Process: 689 ExecStart=/home/pi/Documents/project1/allnewone (code=killed, signal=HUP)
Main PID: 689 (code=killed, signal=HUP)
我的服务文件
#rpi.service
[Unit]
Description= RPi-Service
After = multi-user.target
[Service]
Type = simple
ExecStart = /usr/bin/python3 /home/pi/Documents/project1/allnewone.py
Restart = on-abort
RestartSec = 5
KillMode = process
SendSIGHUP = no
[Install]
WantedBy=multi-user.target
这是解决方案
#rpi.service
[Unit]
Description= RPi-Service
After = multi-user.target
[Service]
Type = simple
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/pi/.Xauthority"
ExecStart = /usr/bin/python3 /home/pi/Documents/project1/allnewone.py
Restart = always
RestartSec = 5
KillMode = process
SendSIGHUP = no
[Install]
WantedBy= graphical.target
我想 运行 pygame 使用 systemd 服务的脚本 按照这些步骤 运行 使用 systemd 服务的 pygame 脚本
sudo systemctl daemon-reload
sudo systemctl enable service_name
sudo systemctl start service_name
并在我的服务不想 运行 一个 pygame 脚本来获得更多理解后重新启动系统
$ sudo journalctl -f -u rpi
-- Logs begin at Thu 2016-11-03 22:46:42 IST. --
Mar 28 12:19:11 raspberrypi systemd[1]: Started RPi-Service.
$sudo systemctl status rpi
rpi.service - RPi-Service
Loaded: loaded (/lib/systemd/system/rpi.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Thu 2019-03-28 12:19:14 IST; 22min ago
Process: 689 ExecStart=/home/pi/Documents/project1/allnewone (code=killed, signal=HUP)
Main PID: 689 (code=killed, signal=HUP)
我的服务文件
#rpi.service
[Unit]
Description= RPi-Service
After = multi-user.target
[Service]
Type = simple
ExecStart = /usr/bin/python3 /home/pi/Documents/project1/allnewone.py
Restart = on-abort
RestartSec = 5
KillMode = process
SendSIGHUP = no
[Install]
WantedBy=multi-user.target
这是解决方案
#rpi.service
[Unit]
Description= RPi-Service
After = multi-user.target
[Service]
Type = simple
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/pi/.Xauthority"
ExecStart = /usr/bin/python3 /home/pi/Documents/project1/allnewone.py
Restart = always
RestartSec = 5
KillMode = process
SendSIGHUP = no
[Install]
WantedBy= graphical.target