I'm currently packaging a python app with dh_virtualenv, daemonized with systemd.
I use the dh_systemd plugin to automatically install the file my_app.service will install the .deb package, but I'd like to run another process in a different service that schedules tasks for my app, using celery.
So, I created another service file, my_app.scheduler.service, but I don't know how to declare this file/app/service in my debian packaging rules, so that while installing the whole package, both services file will be copied and thus will be launched independently.
Here are my debian conf files for dpkg-buildpackage command :
debian/control
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/rules:
#!/usr/bin/make -f
%:
dh $@ --with python-virtualenv --with=systemd
debian/install
etc/my_app.config /etc/
debian/dirs:
/var/lib/my_app
/var/log/my_app
And of course the .service files:
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
Found the solution here:
override_dh_installinit:
dh_installinit --name=service1
dh_installinit --name=service2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With