2000字范文,分享全网优秀范文,学习好帮手!
2000字范文 > python 苹果手机自动重启_在*nix系统中的python中自动重启守护进程

python 苹果手机自动重启_在*nix系统中的python中自动重启守护进程

时间:2024-04-18 13:16:53

相关推荐

python 苹果手机自动重启_在*nix系统中的python中自动重启守护进程

Joseph Victo..

5

如果你在Ubuntu上,我建议你看看暴发户.这样做比inittab但实际上涉及一些学习曲线更好.

编辑(布莱尔):这是我最近为自己的一个程序编写的新手脚本的改编示例.像这样的基本新贵脚本是相当可读/可理解的(虽然很多这样的东西),当你开始做一些奇特的东西时,它们会变得复杂.

description "mydaemon - my cool daemon"

# Start and stop conditions. Runlevels 2-5 are the

# multi-user (i.e, networked) levels. This means

# start the daemon when the system is booted into

# one of these runlevels and stop when it is moved

# out of them (e.g., when shut down).

start on runlevel [2345]

stop on runlevel [!2345]

# Allow the service to respawn automatically, but if

# crashes happen too often (10 times in 5 seconds)

# theres a real problem and we should stop trying.

respawn

respawn limit 10 5

# The program is going to daemonise (double-fork), and

# upstart needs to know this so it can track the change

# in PID.

expect daemon

# Set the mode the process should create files in.

umask 022

# Make sure the log folder exists.

pre-start script

mkdir -p -m0755 /var/log/mydaemon

end script

# Command to run it.

exec /usr/bin/python /path/to/mydaemon.py --logfile /var/log/mydaemon/mydaemon.log

我在我的一个项目中编辑了一个示例upstart脚本,希望你不要介意. (2认同)

如果您正在使用[python-daemon](/pypi/python-daemon/),请注意最好避免使用'expect daemon'节 - python-daemon会发现你正在使用暴发户而且不会双叉. (2认同)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。