[MEGOLDVA] systemd script indítás kivárása

Fórumok

Lenne némi problémám systemd alatt, a kugli meg nagyon nem akar barátkozni csak hülyeséget dob.

Hogy lehet a systemd -nek megmondani hogy várja meg míg lefut az ExecStartban megadott script csak utána vegye elindultnak és lépjen tovább a következő, ettől függő folyamat indítására ?

Illetve miként lehet boot közben elérni az stdoutot, pl kiíratni hogy hol tart az adott script ?

Úgy fest sikerült nagyjából amit szerettem volna. Köszönöm mindenkinek a segítséget és a tippeket.

Megoldás :

-=> /etc/systemd/system/pipacspower.service

[Unit]
Description=Rendszermegsemmisítő brutális lepke-pipacs kombó
Before=munin-node.service vnstat.service
Before=cups.service saned.service
Before=tftpd-hpa.service openvpn.service samba-ad-dc.service nmbd.service
Before=nginx.service mysql.service
Before=dnsmasq.service tor.service polipo.service squid3.service

[Service]
StandardOutput=tty
Type=oneshot
ExecStart=/pipacspower

[Install]
WantedBy=basic.target

-=> /pipacspower

#!/bin/bash
echo "-------------------------------------------------------"
echo -e -n "Nukleáris tél aktiválókód "
for i in {1..30}; do
echo -e -n "$i"
sleep 1
done
echo -e -n " < xterminateallhumans > elfogadva, föld megsemmisítése folyamatban ...\n"
echo "-------------------------------------------------------"
echo alszunk még 10 -et
sleep 10
echo vége

A teszt idejére getty lelőve a tty1 -en :

systemctl disable getty@tty1.service

Hozzászólások

stdout: sehogy, stdout megy Journalba. mivel parhuzamosan mas is indul(hat), ezert az stdoutnak nincs is sok ertelme igy. Van ugyan egy Type=idle, ami bevarja hogy minden mas elinduljon mar ami nem idle, de ez elegge tre megoldas.

Varakozas: Type=oneshot kell neked szerintem.

--
|8]


Behavior of oneshot is similar to simple; however, it is expected that the process has to exit before systemd starts follow-up units. RemainAfterExit= is
particularly useful for this type of service. This is the implied default if neither Type= or ExecStart= are specified.

Akkor az egy bug lesz.

ha rendes service akkor
/etc/systemd/system/multi-user.target.wants/*service
és abban
[Service]
TimeoutStartSec=180

Van egy ilyen opcio:
StandardOutput=tty

MAN:

--default-standard-output=, --default-standard-error=

Sets the default output or error output for all services and sockets, respectively. That is, controls the default for StandardOutput= and StandardError= (see systemd.exec(5) for details). Takes one of inherit, null, tty, journal, journal+console, syslog, syslog+console, kmsg, kmsg+console. If the argument is omitted --default-standard-output= defaults to journal and --default-standard-error= to inherit.

Én a helyedben Type=notify-t használnék, és amikor a saját stuffom elindul, akkor az váltaná ki sd-notify-val a running státuszt.

http://www.freedesktop.org/software/systemd/man/systemd.service.html

Behavior of notify is similar to simple; however, it is expected that the daemon sends a notification message via sd_notify(3) or an equivalent call when it has finished starting up. systemd will proceed with starting follow-up units after this notification message has been sent.

http://www.freedesktop.org/software/systemd/man/systemd-notify.html

Tudom, hogy csunya otlet, de nem feltetlen kell mindent systemd-vel megoldani. Ott a runit, ott a monit, ott van a daemontools, meg egy csapat mas cucc, ami a systemd-tol fuggetlenul a rendelkezesedre all a futtatashoz.
--
Blog | @hron84
Üzemeltető macik