Install multiple .service files with dh_systemd packaging
<p>I'm currently packaging a python app with dh_virtualenv, to deploy it on Ubuntu 16.04, daemonized with systemd.</p>

<p>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. </p>

<p>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.</p>

<p>Do you have any idea to do that ? </p>

<p>Here are my debian conf files for dpkg-buildpackage command : </p>

<p><strong>control</strong></p>

<pre><code>Source: my_app
Section: python
Priority: extra
Maintainer: me
Build-Depends: debhelper (&gt;= 9), python, dh-virtualenv (&gt;= 0.6), dh-systemd (&gt;= 1.5), adduser
Standards-Version: 3.9.5

Package: my_app
Architecture: any
Pre-Depends: dpkg (&gt;= 1.16.1), python2.7, ${misc:Pre-Depends}
Depends: ${python:Depends}, ${misc:Depends}
Description: blabla
</code></pre>

<p><strong>rules</strong></p>

<pre><code>#!/usr/bin/make -f

%:
    dh $@ --with python-virtualenv --with=systemd
</code></pre>

<p><strong>install</strong></p>

<pre><code>etc/my_app.config /etc/
</code></pre>

<p><strong>dirs</strong></p>

<pre><code>/var/lib/my_app
/var/log/my_app
</code></pre>

<p>And of course the .service files :</p>

<p><strong>my_app.service</strong></p>

<pre><code>[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
</code></pre>

<p><strong>my_app.scheduler.service</strong></p>

<pre><code>[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
</code></pre>

<p>Thanks in advance :)</p>

<p><strong>EDIT / SOLUTION</strong></p>

<p>I finally found an answer. For those who might have the same problem, using <a href="http://unix.stackexchange.com/questions/306234/is-it-possible-to-install-two-services-for-one-package-using-dh-installinit-how">dh_installinit</a> solves the case :)</p>

<p>Found the solution <a href="http://%20http://unix.stackexchange.com/questions/306234/is-it-possible-to-install-two-services-for-one-package-using-dh-installinit-how" rel="nofollow">here</a> : </p>

<pre><code>override_dh_installinit:
        dh_installinit --name=service1
        dh_installinit --name=service2
</code></pre>

python virtualenv packaging systemd debhelper