systemd startup script

Nagy Ákos nagy.akos at codespring.ro
Fri May 6 13:38:52 UTC 2016


2016. 05. 06. 16:34 keltezéssel, Nagy Ákos írta:
> 2016. 05. 06. 16:32 keltezéssel, Nagy Ákos írta:
>> 2016. 05. 06. 15:34 keltezéssel, Andrew Shadura írta:
>>> On 06/05/16 14:25, Nagy Ákos wrote:
>>>> 2016. 05. 06. 14:58 keltezéssel, Georges Racinet írta:
>>>>> Hi,
>>>>>
>>>>> On 05/06/2016 01:51 PM, Nagy Ákos wrote:
>>>>>> Hi,
>>>>>>
>>>>>> I wrote a systemd startus script, and test it on Ubuntu 16.04.
>>>>>> I try to create a pull request, but i'm not familiar with it.
>>>>> I'm just a reader here, but I wonder why you use the forking style 
>>>>> and
>>>>> not simply run in the foreground and let systemd handle the
>>>>> daemonization (as you did with celery)
>>>> I don't know exacly the difference between simple and forking...
>>>> First I create script for kallithea, and I left with type=forking, but
>>>> probably work with type=simple too.
>>>> Celeryd work only with type=simple.
>>> Forking means the daemon forks into the background (daemonises), so
>>> systemd has to track that and find the forked process, which is a bit
>>> error-prone. Simple means the daemon doesn't fork but stays in
>>> foreground, and systemd manages it and puts it into the background on
>>> its own. Simple is better for systemd because it's more reliable;
>>> besides, systemd is then able to capture the stderr/stdout and 
>>> direct it
>>> to the system journal automatically.
>>>
>>> Do we really need to provide a separate unit for celeryd? Is it not
>>> possible to start it in some way other than by running paster?
>> Maybe with ExecStartPre= but with simple copying the ExecStart from 
>> celeryd.service don't work.
>> I try kallithea.service with Type=simple, but don't work, only with 
>> forking.
>>
> It work when I remove --daemon:
> ExecStart=/srv/kallithea/venv/bin/paster serve /srv/kallithea/my.ini 
> --pid-file=/srv/kallithea/kallithea.pid 
> --log-file=/srv/kallithea/kallithea.log
>


This script can start celeryd and kallithea in same unit, but because 
celeryd can't run as daemon and I don't know how to run in background, 
termination with time out:

[Unit]
Description=Kallithea and celeryd

[Service]
PIDFile=/srv/kallithea/kallithea.pid
Type=simple
User=kallithea
Group=kallithea
WorkingDirectory=/srv/kallithea/
Environment=VIRTUAL_ENV="$STATEDIR/venv"
Environment=PATH="$VIRTUAL_ENV/bin:$PATH"
ExecStartPre=/srv/kallithea/venv/bin/paster celeryd 
/srv/kallithea/my.ini --pidfile=/srv/kallithea/celeryd.pid 
--logfile=/srv/kallithea/celeryd.log
ExecStart=/srv/kallithea/venv/bin/paster serve /srv/kallithea/my.ini 
--pid-file=/srv/kallithea/kallithea.pid 
--log-file=/srv/kallithea/kallithea.log

[Install]
WantedBy=multi-user.target

-- 
Nagy Ákos
0748219066
SC Softech SRL
Str. Frunzisului, Nr. 29
400664 Cluj



More information about the kallithea-general mailing list