现在的Linux基本用systemd 来管理系统服务(system’s services or daemons)
用户级别的服务
~/.config/systemd/user/python_demo_service.service
查看服务
systemctl --user list-unit-files | grep python_demo_service
参考:
https://github.com/torfsen/python-systemd-tutorial
https://medium.com/codex/setup-a-python-script-as-a-service-through-systemctl-systemd-f0cc55a42267
依赖:
https://github.com/systemd/python-systemd
https://peps.python.org/pep-3143/
https://pypi.org/project/python-daemon/
https://pypi.org/project/setproctitle/
结论:
用systemd ,然后在 main 进程里跑,不需要 daemonalize