Re: s6-svscanboot, how to exit?
On Sat, Jul 15, 2017 at 12:55:59PM -0300, Guillermo wrote: > 2017-07-14 13:00 GMT-03:00 Jean Louis: > > > > However, the VPS servers don't have much option > > left to me, I can install my own system with s6, > > or I can use the ready Debian, Ubuntu and similar. > > OK, quick summary if you are stuck with systemd but want the least > possible interaction with it, and a supervised s6-svscan process. > Untested because I don't have access to a systemd machine and am not > planning to, but it is what I would try. Thank you, good to know! Jean
Re: s6-svscanboot, how to exit?
2017-07-14 13:00 GMT-03:00 Jean Louis: > > However, the VPS servers don't have much option > left to me, I can install my own system with s6, > or I can use the ready Debian, Ubuntu and similar. OK, quick summary if you are stuck with systemd but want the least possible interaction with it, and a supervised s6-svscan process. Untested because I don't have access to a systemd machine and am not planning to, but it is what I would try. Assuming you have s6 and execline binaries in /command and the s6 scan directory in /service, as your OP implies: 1) Copy the s6-svscanboot script from the 'examples' subdirectory of the s6 source tarball to /command. That execline script starts a supervision tree with a catch-all logger implemented with s6-log, which you will probably prefer over the systemd journal, but you need a service directory for it. 2) Install the s6-linux-init package, and do as root: s6-envuidgid xxx s6-linux-init-maker -b /command -l /service -U yyy Where 'xxx' is the efective user you want the catch-all logger to run as. A new subdirectory with the name you specify as 'yyy' will be created in your working directory. 3) Copy the directory named 's6-svscan-log' from yyy/run-image/service to /service. *Do that preserving ownership and permissions!* That is your catch-all logger service directory. 4) Copy the directory named 'uncaught-logs' from yyy/run-image to /service. *Do that preserving ownership and permissions!* That is the s6-log logging directory where your supervision tree messages will go to instead of systemd's journal. 5) Delete the 'redirfd -w 2 /dev/console' line from /service/s6-svscan-log/run, since s6-svscan will not be running as process 1. The catch-all logger's error messages will go to systemd's journal. 6) Put this as /service/.s6-svscan/finish (unless you want to do more there): #!/command/execlineb -P # That is a capital 'X' foreground { s6-svc -X /service/s6-svscan-log } exit 0 That will make the catch-all logger and its s6-supervise parent exit cleanly when the supervision tree is stopped 7) Create a /service/.s6-svscan/env environment directory with the environment variables you want the supervision tree to run with. It should at least contain PATH, because s6-svscanboot contains an 'exec -c' command that will wipe the environment inherited from systemd. 8) Make a /etc/systemd/system/s6-svscan.service service unit file (/etc/systemd/system because it is an administrator-supplied unit file): [Unit] Description=Supervised s6-svscan [Service] #Type=simple is the default ExecStart=/command/s6-svscanboot Restart=always #Could also be Restart=on-failure [Install] WantedBy=multi-user.target After all of this (as root probably): systemctl enable s6-svscan.service should configure systemd to start the supervision tree each time the machine boots. systemctl start s6-svscan.service should start the supervision tree manually. systemctl stop s6-svscan.service should stop the supervision tree manually. G.
Re: s6-svscanboot, how to exit?
On Sat, Jul 15, 2017 at 09:45:51AM +, Laurent Bercot wrote: > > and if I write: service s6 start (after stop), I > > can see I am still bound to console, which is for > > me as user not so clear why. For example nginx > > releases me back to console. > > This is now a systemd question, and you should get help with > systemd user groups, not here; but I see two things that seem > incorrect in your service definition. I don't think "Type=forking" > is correct, because s6-svscan doesn't fork; you probably want > "Type=simple". And "StandardOutput=tty" looks suspicious. > > -- > Laurent Yes, you are right, thank you for the notice. I guess when search engines catch "systemd" words in this mailing list, there will be more attention on s6 tools. In my offices, in few rooms, s6 is running on computers. But on remote VPS, no, due to not being available in "popular" distributions. Jean
Re: s6-svscanboot, how to exit?
Hello Jonathan, On Sat, Jul 15, 2017 at 02:47:39PM +0100, Jonathan de Boyne Pollard wrote: > > Type=forking > > No. > > > StandardOutput=tty > > No. > > > RemainAfterExit=yes > > No. > > > SysVStartPriority=99 > > No. I know I know, I did not read the manuals on systemd. > You're a long-time daemontools user, you say. > Why on Earth do you think that Type=forking is > right? Because I don't think, I copied and it works, if you did not tell me know, it would remain so for years probably. I know I should be more responsible, but I have placed before daemontools in /etc/inittab and just forgot about it, I guess that is wanted effect. > Why on Earth do you think that good daemons fork > and exit parent? I don't think really, and I tried the one-shot method too, but that was not the problem that I was not exiting. This one I changed RemainAfterExit=no and now after systemd "start" it exits. > Why on Earth do you think that svscan -- any > svscan, from daemontools-encore svscan to > s6-svscan -- forks and exits parent? Or needs a > TTY? You are right, I did not check enough. Now I have it better and simpler, after reading your references, but .path is not required in separate file (I guess): cat s6.service [Unit] Description=S6 Supervision ConditionPathExists=/service [Service] ExecStart=/command/s6-svscan /service Restart=always RemainAfterExit=no [Install] WantedBy=multi-user.target and start/stop stuff works with systemd. Thanks much! Jean
Re: s6-svscanboot, how to exit?
> Type=forking No. > StandardOutput=tty No. > RemainAfterExit=yes No. > SysVStartPriority=99 No. You're a long-time daemontools user, you say. Why on Earth do you think that Type=forking is right? Why on Earth do you think that good daemons fork and exit parent? Why on Earth do you think that svscan -- any svscan, from daemontools-encore svscan to s6-svscan -- forks and exits parent? Or needs a TTY? * http://jdebp.eu./FGA/inittab-is-history.html * http://jdebp.eu./FGA/unix-daemon-readiness-protocol-problems.html * http://untroubled.org/daemontools-encore/svscan.8.html * http://www.skarnet.org/software/s6/s6-svscan.html * https://packages.debian.org/sid/runit-systemd * https://packages.debian.org/sid/daemontools-run * https://wiki.archlinux.org/index.php/Runit#Installation * https://wiki.gentoo.org/wiki/Runit#Starting_the_supervision_tree * https://framagit.org/taca/archnosh#nosh-service-manager-only-nosh-run-via-systemd
Re: s6-svscanboot, how to exit?
and if I write: service s6 start (after stop), I can see I am still bound to console, which is for me as user not so clear why. For example nginx releases me back to console. This is now a systemd question, and you should get help with systemd user groups, not here; but I see two things that seem incorrect in your service definition. I don't think "Type=forking" is correct, because s6-svscan doesn't fork; you probably want "Type=simple". And "StandardOutput=tty" looks suspicious. -- Laurent
Re: s6-svscanboot, how to exit?
On Fri, Jul 14, 2017 at 05:51:01PM -0400, Steve Litt wrote: > So you can either do it like you are now, and if s6svscanboot goes down > your whole supervision tree goes down and stays down, or you can make a > systemd unit file for s6 and run it from there, and if s6-svscanboot > goes down it will come right back up. You can probably experiment at > home with a Debian virtual machine host to get just the right unit file > and how to tell it to run itself. As for me is just important to run 3 http daemons under Nginx, now I made it simpler, after recommendations from this list, I have /etc/systemd/system/s6.service: [Unit] Description=S6 Supervision ConditionPathExists=/service [Service] Type=forking ExecStart=/command/s6-svscan /service TimeoutSec=0 StandardOutput=tty RemainAfterExit=yes SysVStartPriority=99 [Install] WantedBy=multi-user.target and if I write: service s6 start (after stop), I can see I am still bound to console, which is for me as user not so clear why. For example nginx releases me back to console. But I press C-c and daemons are running. On reboot everything is fine and running too. Jean
Re: s6-svscanboot, how to exit?
On Fri, Jul 14, 2017 at 09:38:00PM +0100, Jonathan de Boyne Pollard wrote: > Jean Louis: > > Well I made rc-local.service > > Do not do that. Creating a two steps backwards compatibility mechanism, in > order to run s6-svscan under systemd, is daft. > > Jean Louis: > > I just used recipe from stackexchange.com > > You're not reading the right parts of Stack Exchange, obviously. > > * https://askubuntu.com/a/700401/43344 I have in /etc/rc.local -- which I could as well call as I wish, like s6-svscanboot, followin #!/command/execlineb -P /command/redirfd -r 0 /dev/null /command/exec -c -a /command/s6-svscan /command/s6-svscan -t0 /service Then you suggest I could put it directly in .service file, which I think is better idea, but then how? I don't know. I would again need to put some file name in *.service file pointing either to rc.local or whatever I wish to call that script. I will certainly rename it to s6.service Jean