简体   繁体   English

python脚本到.deb ubuntu包安装一个守护进程

[英]python script to .deb ubuntu package to install a daemon

I have a python script which runs a daemon-like service, now I created the python package. 我有一个python脚本,它运行一个类似守护进程的服务,现在我创建了python包。 I created a .deb package from there but I want the script to be run with upstart, but I can't mange to write the files in the /etc/init ubuntu folder automatically when .deb package is installed so that my daemon doesn't have to be started manually on reboot. 我从那里创建了一个.deb包,但我希望脚本能够与upstart一起运行,但是当安装.deb包时,我无法自动编写/ etc / init ubuntu文件夹中的文件,以便我的守护进程不会必须在重启时手动启动。 I don't know if I explained this well, but I don't know how to explain it better... 我不知道我是否解释得这么好,但我不知道如何更好地解释它...

what I have: python_script.py ->runs a python-daemon 我拥有的:python_script.py - >运行一个python-daemon

python_script.tar.gz -> python package python_script.tar.gz - > python包

what I need: 我需要的:

python.deb -> which install the python script and sets up the upstart for my python scrip so that it runs as a service/daemon python.deb - >安装python脚本并为我的python脚本设置upstart,以便它作为服务/守护进程运行

You should look for the debian packaging doc for python , other that can be useful is the stdeb tool, a Python to Debian source package conversion utility. 你应该为python寻找debian打包文档 ,其他可能有用的是stdeb工具,一个Python到Debian源包转换实用程序。

For running it as a daemon you need to create a init.d script (you can see how to here , and here a more complete example), you can add the init.d script in the package and then call "update-rc.d myscript defaults" from the postinst script of the python.deb and call "update-rc.d -f myscript remove" from the prerm script. 要将其作为守护进程运行,您需要创建一个init.d脚本(您可以在此处查看这里有一个更完整的示例),您可以在包中添加init.d脚本,然后调用“update-rc”。 d myscript默认“来自python.deb的postinst脚本,并从prerm脚本调用”update-rc.d -f myscript remove“。

If you are using Ubuntu standard way to create deb package all you need to do is to place package-name.upstart in debian folder. 如果你使用Ubuntu标准方式创建deb包,你需要做的就是将package-name.upstart放在debian文件夹中。

dh_installinit is a debhelper program that is responsible for installing upstart job files or init scripts with associated defaults files into package build directories, and in the former case providing compatibility handling for non-upstart systems. dh_installinit是一个debhelper程序,负责将upstart作业文件或init脚本与关联的默认文件一起安装到包构建目录中,在前一种情况下,为非upstart系统提供兼容性处理。

See dh_installinit . dh_installinit

I find building a Debian package from Bazaar branch to be the easiest way to create deb package. 我发现从Bazaar分支构建Debian软件包是创建deb软件包的最简单方法。

See Packaging New Software as well. 另请参阅打包新软件

I used such approach to create Gearman Job Server set of packages. 我用这种方法创建了Gearman Job Server包。 Placing gearman-job-server.upstart was sufficient. 放置gearman-job-server.upstart就足够了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM