supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
* writing s6 services
@ 2020-10-28  8:01 billa chaitanya
  2020-10-28 14:01 ` Laurent Bercot
  0 siblings, 1 reply; 4+ messages in thread
From: billa chaitanya @ 2020-10-28  8:01 UTC (permalink / raw)
  To: supervision

[-- Attachment #1: Type: text/plain, Size: 504 bytes --]

Hi Team,
Have few doubts while creating service files in s6.

1) Is there a possibility to add an ENV variable dynamically?
I have a shell script which fills out some variables like
IPADDRESS, SERVER  etc .. which I need to use in starting a process later
as part of starting a service/stopping a service.

2) Does s6-supervise has the intelligence of findingout $MAINPID as the
systemd does?(
https://systemd-devel.freedesktop.narkive.com/dpY7US7K/a-little-help-with-mainpid-please
)

Thanks,
chaitanya

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: writing s6 services
  2020-10-28  8:01 writing s6 services billa chaitanya
@ 2020-10-28 14:01 ` Laurent Bercot
  2020-11-03 11:48   ` billa chaitanya
  0 siblings, 1 reply; 4+ messages in thread
From: Laurent Bercot @ 2020-10-28 14:01 UTC (permalink / raw)
  To: billa chaitanya, supervision

>1) Is there a possibility to add an ENV variable dynamically?
>I have a shell script which fills out some variables like
>IPADDRESS, SERVER  etc .. which I need to use in starting a process later
>as part of starting a service/stopping a service.

  You can do whatever you want in a run script, as long as by the end
of it, the pid of the long-running daemon is the pid your run script
was started as.
  If your run script is a shell script, you can absolutely source the
script that fills out your environment variables. It is not the most
idiomatic or safe way to do it, but it will absolutely work.


>2) Does s6-supervise has the intelligence of findingout $MAINPID as the
>systemd does?(
>https://systemd-devel.freedesktop.narkive.com/dpY7US7K/a-little-help-with-mainpid-please

  Yes, that is the point of a process supervisor.
  You don't need a variable such as $MAINPID because the supervisor 
always
remembers the pid of its child. You don't need a pidfile or anything of
the sort.

--
  Laurent


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: writing s6 services
  2020-10-28 14:01 ` Laurent Bercot
@ 2020-11-03 11:48   ` billa chaitanya
  2020-11-03 16:54     ` Guillermo
  0 siblings, 1 reply; 4+ messages in thread
From: billa chaitanya @ 2020-11-03 11:48 UTC (permalink / raw)
  To: Laurent Bercot; +Cc: supervision

[-- Attachment #1: Type: text/plain, Size: 1306 bytes --]

On Wed, Oct 28, 2020 at 7:31 PM Laurent Bercot <ska-supervision@skarnet.org>
wrote:

> >1) Is there a possibility to add an ENV variable dynamically?
> >I have a shell script which fills out some variables like
> >IPADDRESS, SERVER  etc .. which I need to use in starting a process later
> >as part of starting a service/stopping a service.
>
>   You can do whatever you want in a run script, as long as by the end
> of it, the pid of the long-running daemon is the pid your run script
> was started as.
>   If your run script is a shell script, you can absolutely source the
> script that fills out your environment variables. It is not the most
> idiomatic or safe way to do it, but it will absolutely work.
>
>
> >2) Does s6-supervise has the intelligence of findingout $MAINPID as the
> >systemd does?(
> >
> https://systemd-devel.freedesktop.narkive.com/dpY7US7K/a-little-help-with-mainpid-please
>
>   Yes, that is the point of a process supervisor.
>   You don't need a variable such as $MAINPID because the supervisor
> always
> remembers the pid of its child. You don't need a pidfile or anything of
> the sort.
>                So, Is there any variable we can use inside run or finish
> script of a service equivalent to the pid of the  process started inside
> run script?
> --
>   Laurent
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: writing s6 services
  2020-11-03 11:48   ` billa chaitanya
@ 2020-11-03 16:54     ` Guillermo
  0 siblings, 0 replies; 4+ messages in thread
From: Guillermo @ 2020-11-03 16:54 UTC (permalink / raw)
  To: Supervision

El mar., 3 nov. 2020 a las 8:48, billa chaitanya escribió:
>
> >                So, Is there any variable we can use inside run or finish
> > script of a service equivalent to the pid of the  process started inside
> > run script?

The PID of the supervised process will be the same as that of the
'run' script if it is correctly written, so it's $$ for a shell
script, and the value of the environment variable specified to the
getpid program for an execline script.

* http://www.skarnet.org/software/execline/getpid.html

It is not available inside the 'finish' script, but even if it was, it
is no longer useful since, if that script is being executed, the
supervised process has already terminated, and the PID it had has been
'released'.

G.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-03 16:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28  8:01 writing s6 services billa chaitanya
2020-10-28 14:01 ` Laurent Bercot
2020-11-03 11:48   ` billa chaitanya
2020-11-03 16:54     ` Guillermo

supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://inbox.vuxu.org/supervision

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 supervision supervision/ http://inbox.vuxu.org/supervision \
		subscribe@list.skarnet.org
	public-inbox-index supervision

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.supervision.general


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git