Python 应用程序需要 init.d 脚本 [英] Need init.d script for Python application

查看:27
本文介绍了Python 应用程序需要 init.d 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于 python 的应用程序,它的工作方式类似于提要聚合器,需要成为 init.d 脚本的一部分,以便我可以使用启动/停止/重启选项控制执行.此外,我希望将 init.d 脚本设置为 cron 作业(我在这里有示例).

I have a python based application which works like a feed aggregator and needs to be part of init.d script so that I could control the execution with start/stop/restart options. Also I want the init.d script to be setup as a cron job (I have example here).

我在这里找到了一个样本http://homepage.hispeed.ch/py430/python/守护进程

I found one sample here http://homepage.hispeed.ch/py430/python/daemon

(PS.我不希望脚本用python本身编写).

(PS. I don't want the script to be written in python itself).

推荐答案

您可以考虑为使用 Upstart 的操作系统编写 Upstart 任务.

You could consider writing a Upstart task for operating systems which use Upstart.

示例:

# Start zeya
#

description     "Start Zeya music server"

start on startup

task
exec python /home/r00t/code-hacking/serve-music/zeya/src/zeya/zeya.py
--path=/home/r00t/Music

将此添加到文件中,在/etc/init 中说zeya.conf"

Add this to a file, say 'zeya.conf' in /etc/init

然后您可以使用initctl"来控制作业.例如:

and then you can control the job using 'initctl'. For eg:

initctl status zeya
initctl stop zeya

这篇关于Python 应用程序需要 init.d 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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