debian-packaging - 使用 dh_systemd 打包安装多个 .service 文件

标签 debian-packaging

我目前正在用 dh_virtualenv 打包一个 python 应用程序,用 systemd 进行守护。

我使用 dh_systemd 插件自动安装文件 my_app.service 将安装 .deb 包,但我想在不同的服务中运行另一个进程,使用 celery 为我的应用程序安排任务。

所以,我创建了另一个服务文件,my_app.scheduler.service,但我不知道如何在我的 debian 打包规则中声明这个文件/应用程序/服务,所以在安装整个包时,两个服务文件都会被复制,从而独立推出。

这是我的 dpkg-buildpackage 命令的 debian conf 文件:

debian/控制

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

debian/规则:

#!/usr/bin/make -f

%:
    dh $@ --with python-virtualenv --with=systemd

debian/安装

etc/my_app.config /etc/

debian/目录:

/var/lib/my_app
/var/log/my_app

当然还有 .service 文件:

debian/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

debian/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

最佳答案

找到解决方案 here :

override_dh_installinit:
        dh_installinit --name=service1
        dh_installinit --name=service2

关于debian-packaging - 使用 dh_systemd 打包安装多个 .service 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39576120/

相关文章:

debian-packaging - Debian 如何管理软件包名称的冲突?

cmake - 打包 CMake 时 RunCMake 测试失败

debian-packaging - 来自 deb postinst 中的 Apt-get 命令

debhelper - debian 规则文件创建符号链接(symbolic link)

debian-packaging - 如何将软件包构建过程中的额外步骤添加到 debian/rules 中,我应该这样做吗?