Tag: python daemon

Python守护进程和systemd服务

我有简单的Python脚本作为守护进程。 我正在尝试创buildsystemd脚本,以便能够在启动过程中启动此脚本。 当前systemd脚本: [Unit] Description=Text After=syslog.target [Service] Type=forking User=node Group=node WorkingDirectory=/home/node/Node/ PIDFile=/var/run/zebra.pid ExecStart=/home/node/Node/node.py [Install] WantedBy=multi-user.target node.py: if __name__ == '__main__': with daemon.DaemonContext(): check = Node() check.run() run包含while True循环。 我尝试通过systemctl start zebra-node.service运行此服务。 不幸的是,服务没有完成说明序列 – 我不得不按Ctrl + C。 脚本正在运行,但状态正在激活,过了一段时间,它将变为停用状态。 现在我正在使用python守护进程(但在我尝试之前没有它,症状是相似的)。 我应该实施一些额外的function,我的脚本或systemd文件不正确?