我目前正在使用dh_virtualenv打包python应用程序,将其部署在Ubuntu 16.04上,并使用systemd进行守护。
我使用dh_systemd插件自动安装文件my_app.service将安装.deb包,但我想在另一个服务中运行另一个进程,该服务使用celery为我的应用程序安排任务。
所以,我创建了另一个服务文件my_app.scheduler.service,但我不知道如何在我的debian打包规则中声明这个文件/ app / service,这样在安装整个包时,两个服务文件都会被复制,因此将独立发布。
你有任何想法吗?
以下是dpkg-buildpackage命令的debian conf文件:
控制
Source: my_app
Section: python
Priority: extra
Maintainer: me
Build-Depends: debhelper (>= 9), python, dh-virtualenv (>= 0.6), dh-systemd (>= 1.5), adduser
Standards-Version: 3.9.5
Package: my_app
Architecture: any
Pre-Depends: dpkg (>= 1.16.1), python2.7, ${misc:Pre-Depends}
Depends: ${python:Depends}, ${misc:Depends}
Description: blabla
规则
#!/usr/bin/make -f
%:
dh $@ --with python-virtualenv --with=systemd
安装
etc/my_app.config /etc/
显示目录
/var/lib/my_app
/var/log/my_app
当然还有.service文件:
my_app.service
[Unit]
Description=APP
[Service]
Type=simple
User=app_user
EnvironmentFile=/etc/my_app.config
ExecStart=/usr/share/python/my_app/bin/gunicorn -w 10 -b 0.0.0.0:6000 -t 600 my_app_python_package:app
[Install]
WantedBy=multi-user.target
my_app.scheduler.service
[Unit]
Description=APP Scheduler
[Service]
Type=simple
User=app_user
EnvironmentFile=/etc/my_app.config
ExecStart=/usr/share/python/my_app/bin/celery worker -A my_app_python_package.tasks
[Install]
WantedBy=multi-user.targetroot
提前致谢:)
编辑/解决方案
我终于找到了答案。对于那些可能遇到同样问题的人,使用dh_installinit解决了这个问题:)
答案 0 :(得分:8)
找到解决方案here:
override_dh_installinit:
dh_installinit --name=service1
dh_installinit --name=service2
答案 1 :(得分:1)
#!/usr/bin/make -f
%:
dh $@ --with-systemd, python2
override_dh_installinit:
dh_installinit --name=service1
dh_installinit --name=service2
override_dh_systemd_enable:
dh_systemd_enable --name=service1
dh_systemd_enable --name=service2
override_dh_systemd_start:
dh_systemd_start --name=service1
dh_systemd_start --name=service2
将服务名称另存为“ debian /”目录下的“ packagename.service1.service”和“ packagename.service2.service”