如何使用 systemd 服务运行 pygame 脚本? [英] How to Run pygame script using systemd service?

查看:75
本文介绍了如何使用 systemd 服务运行 pygame 脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为此使用 systemd 服务运行 pygame 脚本按照以下步骤使用 systemd 服务运行 pygame 脚本

I Wanted to run pygame script using systemd service for that followed these steps to run a pygame script using systemd service

sudo systemctl daemon-reloadsudo systemctl enable service_namesudo systemctl start service_name

并在此之后重新启动系统,我的服务不想运行 pygame 脚本以获取更多信息

and rebooted the system after that my-service don't want to run a pygame script for more understading

$ sudo journalctl -f -u rpi-- 日志开始于 2016-11-03 星期四 22:46:42 IST.——3 月 28 日 12:19:11 raspberrypi systemd[1]:启动 RPi 服务.

$sudo systemctl status rpirpi.service - RPi 服务已加载:已加载(/lib/systemd/system/rpi.service;已启用;供应商预设:已启用)活动:自 IST 2019-03-28 12:19:14 IST 起不活动(死亡);22 分钟前进程:689 ExecStart=/home/pi/Documents/project1/allnewone(代码=killed,signal=HUP)主 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

这篇关于如何使用 systemd 服务运行 pygame 脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆