Re: s6-svscanboot, how to exit?

2017-07-16 Thread Jean Louis
On Sun, Jul 16, 2017 at 02:00:17AM -0400, Steve Litt wrote:
> On Sat, 15 Jul 2017 18:53:44 +0300
> Jean Louis  wrote:
> 
> > 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.
> 
> And why should you? You're using daemontools to
> escape as many processes as possible out of
> systemd's clutches, and there's nothing wrong
> with copying off stackexchange and letting the
> list know what worked. You're not expected to be
> a systemd expert.

I like simplicite of D.J. Bernstein, and s6 gives me
nice tools for each system without complexities,
in the D.J. Bernstein way.

It is long time ago that I found daemontools, it
was most natural. If I remember well it was even
packaged in Debian systems. init.d could not just
keep everything always running, daemontools could.

> > > 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.
> 
> You don't really need to apologize. You apparently weren't completely
> correct, and it worked well enough to make it seem correct. And some
> guy comes on, gives you four "no"s without reasons, imply that you're
> falsely bragging about being a daemontools user, and then gives you one
> of those "why on earth" type things.

Of course I have seen that, and I don't mind, it
is just my way of handling communication.

You know how people come into fights? When
explaining about the methods of communication
instead of the subject of communication.

So I try to avoid speaking of methods, as it does
not bring much -- but rather of subjects.

> > 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.
> 
> I'm sure you *DIDN'T* think that, and you really don't owe this guy an
> explanation, because he's sure not here to help you.
> 
> Laurent's right. Go on a systemd list or IRC, tell them you need to
> spawn daemontools, tell them daemontools does not put itself in the
> background, and that you want it restarted if it stops. They'll tell
> you what to do. By the way, you might have to tell it to put /command
> on the $PATH. If you need that and you cannot get systemd to handle it,
> I'll give you a shellscript to get it done.

It is related to both, and more to this list I
guess, as people here will know more what is it
about. There would it be as conflict of interest,
just as here, but I guess more there... as a black
sheep in white sheep crowd.

I like reasoning behind daemontools, and Laurent's
reasoning, and that software just works.

The daemontools and now s6 supervision is simply
running 3 tiny web servers accepting the leads
through Nginx, and that is how wealth is created.

Jean


Re: s6-svscanboot, how to exit?

2017-07-16 Thread Steve Litt
On Sat, 15 Jul 2017 18:53:44 +0300
Jean Louis  wrote:

> 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.

And why should you? You're using daemontools to escape as many
processes as possible out of systemd's clutches, and there's nothing
wrong with copying off stackexchange and letting the list know what
worked. You're not expected to be a systemd expert.

> 
> > 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.

You don't really need to apologize. You apparently weren't completely
correct, and it worked well enough to make it seem correct. And some
guy comes on, gives you four "no"s without reasons, imply that you're
falsely bragging about being a daemontools user, and then gives you one
of those "why on earth" type things.

Louis, ignore the guy. His motivation obviously isn't to help. And if
he again asks "why on earth did you think "Type=forking" is right?",
just tell him that for all you knew, that meant it's the type of
software that systemd must fork because it doesn't fork itself. That's
just as plausible.

And when he asks...


> 
> > Why on Earth do you think that good daemons fork
> > and exit parent?  

the answer is that you didn't.

> 
> 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.

I'm sure you *DIDN'T* think that, and you really don't owe this guy an
explanation, because he's sure not here to help you.

Laurent's right. Go on a systemd list or IRC, tell them you need to
spawn daemontools, tell them daemontools does not put itself in the
background, and that you want it restarted if it stops. They'll tell
you what to do. By the way, you might have to tell it to put /command
on the $PATH. If you need that and you cannot get systemd to handle it,
I'll give you a shellscript to get it done.
 
SteveT

Steve Litt 
July 2017 featured book: Quit Joblessness: Start Your Own Business
http://www.troubleshooters.com/startbiz


Re: s6-svscanboot, how to exit?

2017-07-15 Thread Jean Louis
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-15 Thread Guillermo
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?

2017-07-15 Thread Jean Louis
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?

2017-07-15 Thread Jean Louis
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?

2017-07-15 Thread Jonathan de Boyne Pollard
> 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?

2017-07-15 Thread Laurent Bercot

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?

2017-07-15 Thread Jean Louis
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?

2017-07-15 Thread Jean Louis
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


Re: s6-svscanboot, how to exit?

2017-07-14 Thread Steve Litt
On Fri, 14 Jul 2017 22:29:04 +0300
Jean Louis  wrote:

> On Fri, Jul 14, 2017 at 02:31:28PM -0400, Steve Litt wrote:
> > >   If you're fine with it not being supervised and insist on
> > > launching s6-svscanboot from /etc/rc.local, then you want to
> > > enclose all its commands in a "background { }" block, which is
> > > execline's equivalent of the shell's &.  
> > 
> > Or, from sysvinit, you can put it as a respawn in /etc/inittab, so
> > that s6svscanboot itself is supervised, by sysvinit.  
> 
> On that new Debian VPS that I ordered with Digital
> Ocean, there is no /etc/inittab and I don't know
> nothing much about systemd, so I just used recipe
> from stackexchange.com

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.

SteveT

Steve Litt 
July 2017 featured book: Quit Joblessness: Start Your Own Business
http://www.troubleshooters.com/startbiz


Re: s6-svscanboot, how to exit?

2017-07-14 Thread Laurent Bercot

* http://jdebp.eu./FGA/inittab-is-history.html


 Eh, I should have known you had a svscan-under-systemd example
on your site, Jonathan. ;)

--
 Laurent



Re: s6-svscanboot, how to exit?

2017-07-14 Thread Jean Louis
On Fri, Jul 14, 2017 at 03:00:10PM -0500, Brett Neumeier wrote:
> use systemd as init. (I'm also using s6/s6-rc/s6-linux-init on my own
> built-from-source distribution, and prefer it *enormously*, btw).
> 
> What I have is:
> 
> cut here
> ​[Unit]
> Description=s6-svscan
> 
> [Service]
> Type=simple
> Environment=PATH=/opt/s6/bin:/sbin:/bin:/usr/sbin:/usr/bin
> ExecStart=/var/s6scandir/.s6-svscanboot
> Restart=always
> 
> [Install]
> WantedBy=multi-user.target​

I have that one. Thanks.

But i need .s6-svscanboot, can you show me?

Jean


Re: s6-svscanboot, how to exit?

2017-07-14 Thread Brett Neumeier
On Fri, Jul 14, 2017 at 10:58 AM, Laurent Bercot <
ska-supervis...@skarnet.org> wrote:

> Do you have example settings for systemd to start s6-svscan?
>>
> ​[..]​
>
>  But I'm sure somebody somewhere has such an example, and if not, it
> really shouldn't be too hard, because it's a very simple service.
>

​I do! -- because I'm using s6 for process supervision on centos 7, which
use systemd as init. (I'm also using s6/s6-rc/s6-linux-init on my own
built-from-source distribution, and prefer it *enormously*, btw).

What I have is:

cut here
​[Unit]
Description=s6-svscan

[Service]
Type=simple
Environment=PATH=/opt/s6/bin:/sbin:/bin:/usr/sbin:/usr/bin
ExecStart=/var/s6scandir/.s6-svscanboot
Restart=always

[Install]
WantedBy=multi-user.target​
cut here


-- 
Brett Neumeier (bneume...@gmail.com)


Re: s6-svscanboot, how to exit?

2017-07-14 Thread Jean Louis
On Fri, Jul 14, 2017 at 02:31:28PM -0400, Steve Litt wrote:
> >   If you're fine with it not being supervised and insist on launching
> > s6-svscanboot from /etc/rc.local, then you want to enclose all its
> > commands in a "background { }" block, which is execline's equivalent
> > of the shell's &.
> 
> Or, from sysvinit, you can put it as a respawn in /etc/inittab, so that
> s6svscanboot itself is supervised, by sysvinit.

On that new Debian VPS that I ordered with Digital
Ocean, there is no /etc/inittab and I don't know
nothing much about systemd, so I just used recipe
from stackexchange.com

Jean


Re: s6-svscanboot, how to exit?

2017-07-14 Thread Steve Litt
On Fri, 14 Jul 2017 13:14:36 +
"Laurent Bercot"  wrote:

> >The script does not "exist". That means when I do
> >
> >sudo service rc-local stop
> >
> >it stops, and when I do
> >
> >sudo service rc-local start
> >
> >it is then hanging, or running, it is fine, but I
> >would like to exit back to shell on such run.
> >
> >Adding & on end of line is not helping.
> >
> >How do I make it execute and exit back to shell?  
> 
>   You don't, if you want it supervised. If you want to launch
> s6-svscan under systemd, you should write a proper unit file for it,
> so systemd can manage it as one of its services.
> 
>   If you're fine with it not being supervised and insist on launching
> s6-svscanboot from /etc/rc.local, then you want to enclose all its
> commands in a "background { }" block, which is execline's equivalent
> of the shell's &.

Or, from sysvinit, you can put it as a respawn in /etc/inittab, so that
s6svscanboot itself is supervised, by sysvinit.

 
SteveT

Steve Litt 
July 2017 featured book: Quit Joblessness: Start Your Own Business
http://www.troubleshooters.com/startbiz


Re: s6-svscanboot, how to exit?

2017-07-14 Thread Jean Louis
Hello Laurent,

I see that as a principle, and I support it.

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.

Anyway, right now it works, even if it starts, and
I interrupt it, it continues working due to
supervisor probably.

I just switched from daemontools which I used for
years to s6 software as it is maintained, even I
never had problems with daemontools, it just
works like s6.

Jean

On Fri, Jul 14, 2017 at 03:58:43PM +, Laurent Bercot wrote:
> > Do you have example settings for systemd to
> > start s6-svscan?
> 
>  I don't, sorry. I never bothered to learn the
> syntax, and I kinda omitted systemd from the
> https://skarnet.org/software/s6/s6-svscan-not-1.html
> page on purpose.
> 
>  But I'm sure somebody somewhere has such an example, and if not, it
> really shouldn't be too hard, because it's a very simple service.
> 
> --
>  Laurent
> 


Re: s6-svscanboot, how to exit?

2017-07-14 Thread Laurent Bercot

Do you have example settings for systemd to start s6-svscan?


 I don't, sorry. I never bothered to learn the syntax, and I kinda
omitted systemd from the 
https://skarnet.org/software/s6/s6-svscan-not-1.html

page on purpose.

 But I'm sure somebody somewhere has such an example, and if not, it
really shouldn't be too hard, because it's a very simple service.

--
 Laurent



Re: s6-svscanboot, how to exit?

2017-07-14 Thread Laurent Bercot

The script does not "exist". That means when I do

sudo service rc-local stop

it stops, and when I do

sudo service rc-local start

it is then hanging, or running, it is fine, but I
would like to exit back to shell on such run.

Adding & on end of line is not helping.

How do I make it execute and exit back to shell?


 You don't, if you want it supervised. If you want to launch s6-svscan
under systemd, you should write a proper unit file for it, so systemd
can manage it as one of its services.

 If you're fine with it not being supervised and insist on launching
s6-svscanboot from /etc/rc.local, then you want to enclose all its
commands in a "background { }" block, which is execline's equivalent
of the shell's &.

--
 Laurent