[systemd-devel] Timeout for 'Activating (start)' status

Mikhail Kasimov mikhail.kasimov at gmail.com
Tue Jul 11 11:46:07 UTC 2017


Hello!


11.07.2017 13:49, Lennart Poettering пишет:
> On Thu, 06.07.17 16:43, Mikhail Kasimov (mikhail.kasimov at gmail.com) wrote:
>
>> Hello!
>>
>> 've got an interesting trouble on timer-activated service -- 'systemctl
>> status' returns a log with 'Activating (start)' status:
>>
>> [1]
>> ==========
>> k_mikhail at linux-mk500:~> systemctl status vba32update.service
>> ● vba32update.service - VBA32 Anti-Virus Update Service
>>    Loaded: loaded (/etc/systemd/system/vba32update.service; disabled;
>> vendor preset: disabled)
>>    Active: activating (start) since Чтв 2017-07-06 15:32:35 EEST; 35min ago
>>  Main PID: 6214 (vbaupdx)
>>     Tasks: 1 (limit: 512)
>>    CGroup: /system.slice/vba32update.service
>>            └─6214 ./vbaupdx http://anti-virus.by/beta/update
>>
>> Июл 06 15:32:35 linux-mk500 systemd[1]: Starting VBA32 Anti-Virus Update
>> Service...
>> Июл 06 15:32:35 linux-mk500 vbacl[6214]: Vba32 console scanner update
>> process started
>> Июл 06 15:32:35 linux-mk500 vbacl[6214]: Reading configuration options
>> from ./vbacl.ini
>> Июл 06 15:32:35 linux-mk500 vbacl[6214]: Using direct connection for update
>> k_mikhail at linux-mk500:~>
>> ==========
>>
>>
>> Simultaneously:
>> [2]
>> ==========
>> k_mikhail at linux-mk500:~> systemctl list-units -t timer
>> UNIT                         LOAD   ACTIVE SUB     DESCRIPTION
>> vba32update.timer            loaded active running Runs VBA32 Update Hourly
>> ==========
>>
>> And that is normal. But 35 minutes for activating service is too long,
>> as for me.
> Well, process 6214 is still around as you can see above, and since you
> appear to have set Type=oneshot, that's really the right behaviour:
> the unit will be starting until process 6214 decides. if 35min is too
> long for that process, then this indicates that something is wrong in
> that process, and systemd is just the messenger.
>
> If you want to place a timeout on starting use TimeoutStartSec= and
> set it to whatever you like. If the timeout is then hit, systemd will
> abort the process and log about this and place the service in a failed
> state.

No problem at all. I 've modified vba32update.service by adding
TimeoutStarSec= and Restart=on-failure directives, because I wanna force
to restart service automatically if it gets 'failed' status.

[1]
========================
k_mikhail at linux-mk500:~> cat vba32update.service
[Unit]

Description=VBA32 Anti-Virus Update Service
Requires=network.target
Wants=network-online.target
After=network.target network-online.target

[Service]
Type=oneshot
WorkingDirectory=/opt/vba/vbacl/
ExecStart=/opt/vba/vbacl/vbacl --update
EnvironmentFile=/opt/vba/vbacl/vbacl.ini
TimeoutStartSec=120s
Restart=on-failure

[Install]
WantedBy=multi-user.target
========================


Then attempt to vba32update.service:
========================
k_mikhail at linux-mk500:~> systemctl status -l vba32update.service
● vba32update.service - VBA32 Anti-Virus Update Service
   Loaded: error (Reason: Invalid argument)
   Active: activating (start) since Вто 2017-07-11 02:48:54 EEST; 11h ago
 Main PID: 22712 (vbaupdx)
   CGroup: /system.slice/vba32update.service
           └─22712 ./vbaupdx http://anti-virus.by/beta/update

Июл 11 02:48:54 linux-mk500 systemd[1]: Starting VBA32 Anti-Virus Update
Service...
Июл 11 02:48:54 linux-mk500 vbacl[22712]: Vba32 console scanner update
process started
Июл 11 02:48:54 linux-mk500 vbacl[22712]: Reading configuration options
from ./vbacl.ini
Июл 11 02:48:54 linux-mk500 vbacl[22712]: Using direct connection for update
Июл 11 14:22:19 linux-mk500 systemd[1]: vba32update.service: Service has
Restart= setting other than no, which isn't allowed for Type=oneshot
services. Refusing.
========================

Brilliant. Let's go to man-page
https://www.freedesktop.org/software/systemd/man/systemd.service.html on
Restart= directive text and we can see _no_ _info_ about such
restriction. Lack-of-info on documentaion.

Or, please, give a hint how service, which works in 'start -> do
something->exit' scheme (so this is oneshot type, as I understand:
https://www.freedesktop.org/software/systemd/man/systemd.service.html :
"Behavior of |oneshot| is similar to |simple|; however, it is expected
that the *process has to exit* before systemd starts follow-up units."),
be forced to be restarted on its failure.
>
> But systemd is not a magic wand that can make hanging processes
> suddenly work...

I understand it. I just try to find the way how to resolve my usecase
problem by options, which systemd provides.

Thanks!




More information about the systemd-devel mailing list