[systemd-devel] Best approach to run python service in virtualenv with systemd
Lennart Poettering
mzerqung at 0pointer.de
Thu Apr 14 09:38:37 UTC 2016
On Wed, 13.04.16 15:14, Stanislav Kopp (staskopp at gmail.com) wrote:
> Hi all,
>
> I'm trying to run kallithea using virtualenv, it kinda works (I can
> stop/start service) with this unit file
>
> ########################################
> [Unit]
> Description=Start Kallithea service
> After=network.target
>
> [Service]
> Type=forking
> User=kallithea
> WorkingDirectory=/srv/kallithea
> ExecStart=/srv/kallithea/venv/bin/python2
> /srv/kallithea/venv/bin/paster serve --daemon
> --pid-file=/srv/kallithea/kallithea.pid
> --log-file=/srv/kallithea/kallithea.log my.ini
> PIDFile=/srv/kallithea/kallithea.pid
>
> [Install]
> WantedBy=multi-user.target
> #########################################
>
> but I always see "Failed to read PID from file
> /srv/kallithea/kallithea.pid: Invalid argument" in "systemctl status",
> I know that "PIDFile" option isn't a best practice and should be
> avoided, but withou it service doesn't running.
> Is there any better methods to run it or at least remove this pid error message?
Hmm, EINVAL? that's strange. What's the precise contents of that file?
Maybe your service is storing the PID file in an invalid format? It
should really be a simple text file with one line containing the ascii
formatted PID number...
Lennart
--
Lennart Poettering, Red Hat
More information about the systemd-devel
mailing list