06.07.2017 19:12, Mikhail Kasimov пишет: > > 06.07.2017 18:27, Michael Chapman пишет: >> On Fri, 7 Jul 2017, Mikhail Kasimov wrote: >>> 06.07.2017 17:18, Michael Chapman пишет: >>>> On Thu, 6 Jul 2017, Mikhail Kasimov wrote: >>>>> Hello! >>>>> >>>>> 've got an interesting trouble on timer-activated service -- >>>>> 'systemctl >>>>> status' returns a log with 'Activating (start)' status: >>>>> >>>>> [1] >>>>> ========== >>>>> k_mikhail@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@linux-mk500:~> >>>>> ========== >>>>> >>>>> >>>>> Simultaneously: >>>>> [2] >>>>> ========== >>>>> k_mikhail@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. >>>> Is this a Type=oneshot service? >>>> >>>> It's a bit weird, but Type=oneshot services are not considered to be >>>> fully started until the ExecStart= command has exited. Until that time >>>> they're still "activating". >>>> >>>> You may be better off making the service Type=simple instead. A >>>> Type=simple service is fully started as soon as it has spawned the >>>> ExecStart= command. >>> Yes, Type=oneshot, because, if Type=simple, service will be active >>> permanently in case of its start. But this is not what is needed here -- >>> service should be started, then to check the updates of anti-virus >>> software and then be successfully closed. Nothing more. Only one thing >>> can impact here -- remote anti-virus server connection timeout. And if >>> server connection timeout is set in wrong way, having a native systemd >>> forced timeout for oneshot-services may be useful. >> I still think you want Type=simple there. A Type=simple service can >> exit when it's finished doing whatever it needs to do. The service >> will then transition back to its inactive state. >> >> Really, I think the only time Type=oneshot should be used is when you >> have a _sequence_ of units, where one unit shouldn't be started until >> the previous one has finished. You don't have that here. > Ok, here is Type=oneshot. And we can see two sessions of our service > (at1 7:06:52 and 18:06:57): > ================== > [1] > Июл 06 17:06:52 linux-mk500 systemd[1]: Starting VBA32 Anti-Virus Update > Service... > Июл 06 17:06:52 linux-mk500 vbacl[8058]: Vba32 console scanner update > process started > Июл 06 17:06:52 linux-mk500 vbacl[8058]: Reading configuration options > from ./vbacl.ini > Июл 06 17:06:52 linux-mk500 vbacl[8058]: Using direct connection for update > Июл 06 17:06:56 linux-mk500 vbacl[8058]: Current dir is ./ > Июл 06 17:06:56 linux-mk500 vbacl[8058]: Start update from > http://anti-virus.by/beta/update > Июл 06 17:06:56 linux-mk500 vbacl[8058]: Receiving file list > Июл 06 17:06:56 linux-mk500 vbacl[8058]: File list received > Июл 06 17:06:56 linux-mk500 vbacl[8058]: Update is not needed > Июл 06 17:06:57 linux-mk500 systemd[1]: Started VBA32 Anti-Virus Update > Service. > > [2] > Июл 06 18:06:57 linux-mk500 systemd[1]: Starting VBA32 Anti-Virus Update > Service... > Июл 06 18:06:57 linux-mk500 vbacl[8842]: Vba32 console scanner update > process started > Июл 06 18:06:57 linux-mk500 vbacl[8842]: Reading configuration options > from ./vbacl.ini > Июл 06 18:06:57 linux-mk500 vbacl[8842]: Using direct connection for update > Июл 06 18:07:00 linux-mk500 vbacl[8842]: Current dir is ./ > Июл 06 18:07:00 linux-mk500 vbacl[8842]: Start update from > http://anti-virus.by/beta/update > Июл 06 18:07:00 linux-mk500 vbacl[8842]: Receiving file list > Июл 06 18:07:00 linux-mk500 vbacl[8842]: File list received > Июл 06 18:07:00 linux-mk500 vbacl[8842]: Update is not needed > Июл 06 18:07:00 linux-mk500 systemd[1]: Started VBA32 Anti-Virus Update > Service. > ================== > > > And here when Type=simple: > ================== > Июл 06 18:47:29 linux-mk500 systemd[1]: Started VBA32 Anti-Virus Update > Service. > Июл 06 18:47:29 linux-mk500 vbacl[10042]: Vba32 console scanner update > process started > Июл 06 18:47:29 linux-mk500 vbacl[10042]: Reading configuration options > from ./vbacl.ini > Июл 06 18:47:29 linux-mk500 vbacl[10042]: Using direct connection for update > ================== > > 'systemctl status' output here: > ============================ > k_mikhail@linux-mk500:~> systemctl status -l vba32update.service > ● vba32update.service - VBA32 Anti-Virus Update Service > Loaded: loaded (/etc/systemd/system/vba32update.service; disabled; > vendor preset: disabled) > Active: active (running) since Чтв 2017-07-06 18:47:29 EEST; 13min ago > Main PID: 10042 (vbaupdx) > Tasks: 1 (limit: 512) > CGroup: /system.slice/vba32update.service > └─10042 ./vbaupdx http://anti-virus.by/beta/update > > Июл 06 18:47:29 linux-mk500 systemd[1]: Started VBA32 Anti-Virus Update > Service. > Июл 06 18:47:29 linux-mk500 vbacl[10042]: Vba32 console scanner update > process started > Июл 06 18:47:29 linux-mk500 vbacl[10042]: Reading configuration options > from ./vbacl.ini > Июл 06 18:47:29 linux-mk500 vbacl[10042]: Using direct connection for update > ============================ > > Service is _still_active_ and this is not what is needed here. The > service behavior correct is when it has Type=oneshot _only_. > > " Type=simple service can exit when it's finished doing whatever it > needs to do. The service will then transition back to its inactive > state." -- as you can see, no. And in this case (when Type=oneshot), we > have to be able to close 'Activating (start)'-stated service, if this > status is on for a long time. I understand, that my use-case is very > specific, but it is real. So, let's try to find the method together. > > > To be more informative, here are 'systemctl cat' outputs both for > .service and .timer: > > k_mikhail@linux-mk500:~> systemctl cat vba32update.service > =============================================== > # /etc/systemd/system/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 > > [Install] > WantedBy=multi-user.target > =============================================== > > =============================================== > k_mikhail@linux-mk500:~> systemctl cat vba32update.timer > # /etc/systemd/system/vba32update.timer > [Unit] > Description=Runs VBA32 Update Hourly > Requires=timers.target > > [Timer] > OnBootSec=2min > OnUnitInactiveSec=1h > AccuracySec=1us > > [Install] > WantedBy=timers.target > k_mikhail@linux-mk500:~> > ===============================================
UPD: BTW, when I (re-)start service manually, it works as expected (service is getting started, then checks for updates, then is getting exited): k_mikhail@linux-mk500:~> sudo systemctl restart vba32update.service k_mikhail@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: inactive (dead) since Чтв 2017-07-06 19:14:33 EEST; 23s ago Process: 10476 ExecStart=/opt/vba/vbacl/vbacl --update (code=exited, status=0/SUCCESS) Main PID: 10476 (code=exited, status=0/SUCCESS) Июл 06 19:14:30 linux-mk500 systemd[1]: Starting VBA32 Anti-Virus Update Service... Июл 06 19:14:30 linux-mk500 vbacl[10476]: Vba32 console scanner update process started Июл 06 19:14:30 linux-mk500 vbacl[10476]: Reading configuration options from ./vbacl.ini Июл 06 19:14:30 linux-mk500 vbacl[10476]: Using direct connection for update Июл 06 19:14:33 linux-mk500 vbacl[10476]: Current dir is ./ Июл 06 19:14:33 linux-mk500 vbacl[10476]: Start update from http://anti-virus.by/beta/update Июл 06 19:14:33 linux-mk500 vbacl[10476]: Receiving file list Июл 06 19:14:33 linux-mk500 vbacl[10476]: File list received Июл 06 19:14:33 linux-mk500 vbacl[10476]: Update is not needed Июл 06 19:14:33 linux-mk500 systemd[1]: Started VBA32 Anti-Virus Update Service. _______________________________________________ systemd-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/systemd-devel
