* [gentoo-dev] s6.eclass: new eclass for installing s6 services
@ 2015-06-01 17:13 William Hubbs
2015-06-01 17:24 ` Michał Górny
2015-06-01 17:39 ` Brian Evans
0 siblings, 2 replies; 9+ messages in thread
From: William Hubbs @ 2015-06-01 17:13 UTC (permalink / raw
To: gentoo development
[-- Attachment #1.1: Type: text/plain, Size: 287 bytes --]
All,
we are starting to add support for s6 service supervision to Gentoo, so
I would like to add an eclass to facilitate the installation of s6
services.
Please take a look and let me know what you think.
If no one objects, I will commit this to the tree on 3 Jun.
Thanks,
William
[-- Attachment #1.2: s6.eclass --]
[-- Type: text/plain, Size: 1800 bytes --]
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: s6.eclass
# @MAINTAINER:
# William Hubbs <williamh@gentoo.org>
# @BLURB: helper functions to install s6 services
# @DESCRIPTION:
# This eclass provides a helper to install s6 services.
# @EXAMPLE:
#
# @CODE
# inherit s6
#
# src_install() {
# ...
# s6_doservice myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
# s6_doservice myservice/log "${FILESDIR}"/log-run-s6 \
# "${FILESDIR}"/log-finish-s6
# ...
# }
# @CODE
case ${EAPI:-0} in
0|1|2|3|4|5) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac
# @FUNCTION: _s6_get_servicedir
# @INTERNAL
# @DESCRIPTION:
# Get unprefixed servicedir.
_s6_get_servicedir() {
echo /var/svc.d
}
# @FUNCTION: s6_get_servicedir
# @DESCRIPTION:
# Output the path for the s6 service directory (not including ${D}).
s6_get_servicedir() {
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_s6_get_servicedir)"
}
# @FUNCTION: s6_doservice
# @USAGE: servicename run finish
# @DESCRIPTION:
# Install an s6 service.
# servicename is the name of the service.
# run is the run script for the service.
# finish is the optional finish script for the service.
# This function is fatal in eapis newer than 4 and non-fatal otherwise.
s6_doservice() {
debug-print-function ${FUNCNAME} "${@}"
local name="$1"
local run="$2"
local finish="$3"
[[ $name ]] ||
die "${ECLASS}.eclassYou must specify the s6 service name."
[[ $run ]] ||
die "${ECLASS}.eclass: You must specify the s6 service run script."
(
local servicepath="$(_s6_get_servicedir)/$name"
exeinto "$servicepath"
newexe "$run" run
[[ $finish ]] && newexe "$finish" finish
)
}
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-01 17:13 [gentoo-dev] s6.eclass: new eclass for installing s6 services William Hubbs
@ 2015-06-01 17:24 ` Michał Górny
2015-06-01 17:30 ` William Hubbs
2015-06-01 17:39 ` Brian Evans
1 sibling, 1 reply; 9+ messages in thread
From: Michał Górny @ 2015-06-01 17:24 UTC (permalink / raw
To: William Hubbs; +Cc: gentoo development
[-- Attachment #1: Type: text/plain, Size: 794 bytes --]
Dnia 2015-06-01, o godz. 12:13:52
William Hubbs <williamh@gentoo.org> napisał(a):
> # @FUNCTION: s6_get_servicedir
> # @DESCRIPTION:
> # Output the path for the s6 service directory (not including ${D}).
> s6_get_servicedir() {
> has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
How about killing some support for ancient EAPIs? The less people can
use them, the better for ebuild migration.
> debug-print-function ${FUNCNAME} "${@}"
>
> echo "${EPREFIX}$(_s6_get_servicedir)"
> }
>
> # @FUNCTION: s6_doservice
> # @USAGE: servicename run finish
Please don't name it 'do*' if it doesn't match the usual do-function
usage, i.e. 'dofoo file1 file2...'. That's why I created
'systemd_install_serviced' and not 'doserviced'.
--
Best regards,
Michał Górny
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 949 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-01 17:24 ` Michał Górny
@ 2015-06-01 17:30 ` William Hubbs
0 siblings, 0 replies; 9+ messages in thread
From: William Hubbs @ 2015-06-01 17:30 UTC (permalink / raw
To: gentoo-dev; +Cc: mgorny
[-- Attachment #1: Type: text/plain, Size: 1101 bytes --]
On Mon, Jun 01, 2015 at 07:24:26PM +0200, Michał Górny wrote:
> Dnia 2015-06-01, o godz. 12:13:52
> William Hubbs <williamh@gentoo.org> napisał(a):
>
> > # @FUNCTION: s6_get_servicedir
> > # @DESCRIPTION:
> > # Output the path for the s6 service directory (not including ${D}).
> > s6_get_servicedir() {
> > has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
>
> How about killing some support for ancient EAPIs? The less people can
> use them, the better for ebuild migration.
That's easy enough. In that case I would start support at eapi 5.
>
> > debug-print-function ${FUNCNAME} "${@}"
> >
> > echo "${EPREFIX}$(_s6_get_servicedir)"
> > }
> >
> > # @FUNCTION: s6_doservice
> > # @USAGE: servicename run finish
>
> Please don't name it 'do*' if it doesn't match the usual do-function
> usage, i.e. 'dofoo file1 file2...'. That's why I created
> 'systemd_install_serviced' and not 'doserviced'.
Ok, it would be easy enough to name it s6_install_service. There can't
be a do* in this case then because an s6 service is not just a simple
file.
William
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-01 17:13 [gentoo-dev] s6.eclass: new eclass for installing s6 services William Hubbs
2015-06-01 17:24 ` Michał Górny
@ 2015-06-01 17:39 ` Brian Evans
2015-06-01 18:24 ` William Hubbs
1 sibling, 1 reply; 9+ messages in thread
From: Brian Evans @ 2015-06-01 17:39 UTC (permalink / raw
To: gentoo-dev
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 6/1/2015 1:13 PM, William Hubbs wrote:
> All,
>
> we are starting to add support for s6 service supervision to
> Gentoo, so I would like to add an eclass to facilitate the
> installation of s6 services.
>
> Please take a look and let me know what you think.
>
> If no one objects, I will commit this to the tree on 3 Jun.
>
Can support be added for a run/finish log script?
Should be no big deal to add what amounts to
doexe $(s6_get_servicedir)/$name/log
newexe run-s6 run
Otherwise i may just cheat and use $name/log as the name on a second
call since the eclass does not do any $name validation.
Thanks
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
iQIcBAEBAgAGBQJVbJi1AAoJENH3ge/59KO2MZQP/2fc8nVlFkjXJGGFVchTKhwK
XvUAB9PmF2oRz5xOPAbhfQc1YgQaVLDqFV/PrNHfN/gmcUnfvRv2JnSFEqw6Qv7O
aCOQenVF6WhQjfxxfolZjBMX7M0rM2XgXQ8aHEov1JkQyV/1JXUr4MsLAyZwLE9v
Di8MLcxZv/diJI3cqqiPucoehi/sPxQdc37mPbw3uGN+oWOzTMmwmUaPUEcvq2Pu
gmtX6YA/A+1O/4pDXO7zJedHHFsluAlaUcuHJSp0LJ7RnfyFy0ZXqS4TjXs+N8q/
dPr51cKrL3bU1vLrOWQLHXvWHZIm3Uc3Po3P2x2AvqZpebltSFVZzaEq/e/DXrSK
bgRpOzwTXMENHPM6cUr/GiebbAD+m3WG9TkS+wcd1C25NSsq+ocZQDJjaLf+VfpK
hwZ1uIUy0Ux0LmdyGnnDNl8pWORldbtlC/tWjL3ZYf7OWVkRckxAoQ6lLSdf9qa/
pU2qO68bE3iDLL5r48QVmy4Xc1A1/zqge3vxvxG6DyerXJYRWF4OF23fSbCpdrQi
BBRNE2p6g9jgJIps96iCL89DOdRAg6zopcMwZEO+e4cOHmAewxGFunsnCQAYsMIV
9EMUQH2l1vDwoKNglIgB6o/knGpjapJGgeU4IGlIjKjnuSucSaIYtquIqU5HagOR
N+70MyEB9VVn0fgUneSa
=OciI
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-01 17:39 ` Brian Evans
@ 2015-06-01 18:24 ` William Hubbs
2015-06-01 21:08 ` William Hubbs
0 siblings, 1 reply; 9+ messages in thread
From: William Hubbs @ 2015-06-01 18:24 UTC (permalink / raw
To: gentoo-dev; +Cc: grknight
[-- Attachment #1: Type: text/plain, Size: 1428 bytes --]
On Mon, Jun 01, 2015 at 01:39:01PM -0400, Brian Evans wrote:
> Can support be added for a run/finish log script?
> Should be no big deal to add what amounts to
>
> doexe $(s6_get_servicedir)/$name/log
> newexe run-s6 run
>
> Otherwise i may just cheat and use $name/log as the name on a second
> call since the eclass does not do any $name validation.
I'm open to it, I'm just not sure how I would make it happen since the
finish script for the service itself is optional. For example:
s6_install_service service script-1 script-2
In the above, script-2 is optional and could either be the finish script
for ${service} or the run script for ${service}/log, which is a service
itself.
The only way I can think of to allow service and log service
installation at the same time would be to use a reserved value such as
"none" to indicate that a script should be skipped. If I did that, to
install a run script and a log run script might look like:
s6_install_service service run-script none log-run-script
If you have a finish script, the call would be:
s6_install_service service run-script finish-script log-run-script
For either of these calls, there would also be an optional final
argument which would be the log-finish-script.
The tradeoff here would be that whatever I choose to indicate that a
script is skipped can't be used as a file name.
What do you think?
William
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-01 18:24 ` William Hubbs
@ 2015-06-01 21:08 ` William Hubbs
2015-06-01 21:14 ` Tim Harder
0 siblings, 1 reply; 9+ messages in thread
From: William Hubbs @ 2015-06-01 21:08 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 128 bytes --]
All,
here is an updated version of the eclass after receiving feedback on
IRC.
Let me know what you think.
Thanks,
William
[-- Attachment #1.2: s6.eclass --]
[-- Type: text/plain, Size: 2730 bytes --]
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: s6.eclass
# @MAINTAINER:
# William Hubbs <williamh@gentoo.org>
# @BLURB: helper functions to install s6 services
# @DESCRIPTION:
# This eclass provides helpers to install s6 services.
# @EXAMPLE:
#
# @CODE
# inherit s6
#
# src_install() {
# ...
# s6_install_service myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
...
# If you want a service to be logged, install the log service as
# shown here.
# s6_install_service myservice/log "${FILESDIR}"/log-run-s6 \
# "${FILESDIR}"/log-finish-s6
# ...
# }
# @CODE
case ${EAPI:-0} in
5) ;;
*) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
esac
# @FUNCTION: _s6_get_servicedir
# @INTERNAL
# @DESCRIPTION:
# Get unprefixed servicedir.
_s6_get_servicedir() {
echo /var/svc.d
}
# @FUNCTION: s6_get_servicedir
# @DESCRIPTION:
# Output the path for the s6 service directory (not including ${D}).
s6_get_servicedir() {
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_s6_get_servicedir)"
}
# @FUNCTION: s6_install_service
# @USAGE: servicename run finish
# @DESCRIPTION:
# Install an s6 service.
# servicename is the name of the service.
# run is the run script for the service.
# finish is the optional finish script for the service.
s6_install_service() {
debug-print-function ${FUNCNAME} "${@}"
local name="$1"
local run="$2"
local finish="$3"
[[ $name ]] ||
die "${ECLASS}.eclassYou must specify the s6 service name."
[[ $run ]] ||
die "${ECLASS}.eclass: You must specify the s6 service run script."
(
local servicepath="$(_s6_get_servicedir)/$name"
exeinto "$servicepath"
newexe "$run" run
[[ $finish ]] && newexe "$finish" finish
)
}
# @FUNCTION: s6_service_down
# @USAGE: servicename
# @DESCRIPTION:
# Install the "down" flag so this service will not be started by
# default.
# servicename is the name of the service.
s6_service_down() {
debug-print-function ${FUNCNAME} "${@}"
local name="$1"
[[ $name ]] ||
die "${ECLASS}.eclassYou must specify the s6 service name."
(
touch "$T"/down || die
local servicepath="$(_s6_get_servicedir)/$name"
insinto "$servicepath"
doins "$T"/down
)
}
# @FUNCTION: s6_service_nosetsid
# @USAGE: servicename
# @DESCRIPTION:
# Install the "nosetsid" flag so this service will not be made a session
# leader.
# servicename is the name of the service.
s6_service_nosetsid() {
debug-print-function ${FUNCNAME} "${@}"
local name="$1"
[[ $name ]] ||
die "${ECLASS}.eclassYou must specify the s6 service name."
(
touch "$T"/nosetsid || die
local servicepath="$(_s6_get_servicedir)/$name"
insinto "$servicepath"
doins "$T"/nosetsid
)
}
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-01 21:08 ` William Hubbs
@ 2015-06-01 21:14 ` Tim Harder
2015-06-02 15:08 ` William Hubbs
0 siblings, 1 reply; 9+ messages in thread
From: Tim Harder @ 2015-06-01 21:14 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 265 bytes --]
On 2015-06-01 17:08, William Hubbs wrote:
> [[ $name ]] ||
> die "${ECLASS}.eclassYou must specify the s6 service name."
This looks like it's missing a colon and space after ${ECLASS}.eclass,
note that this typo appears to be copied to a few other places.
Tim
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-01 21:14 ` Tim Harder
@ 2015-06-02 15:08 ` William Hubbs
2015-06-02 21:10 ` William Hubbs
0 siblings, 1 reply; 9+ messages in thread
From: William Hubbs @ 2015-06-02 15:08 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1.1: Type: text/plain, Size: 97 bytes --]
All,
here is the updated version of the eclass; I believe I fixed all typos.
Thanks,
William
[-- Attachment #1.2: s6.eclass --]
[-- Type: text/plain, Size: 2732 bytes --]
# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# @ECLASS: s6.eclass
# @MAINTAINER:
# William Hubbs <williamh@gentoo.org>
# @BLURB: helper functions to install s6 services
# @DESCRIPTION:
# This eclass provides helpers to install s6 services.
# @EXAMPLE:
#
# @CODE
# inherit s6
#
# src_install() {
# ...
# s6_install_service myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
...
# If you want a service to be logged, install the log service as
# shown here.
# s6_install_service myservice/log "${FILESDIR}"/log-run-s6 \
# "${FILESDIR}"/log-finish-s6
# ...
# }
# @CODE
case ${EAPI:-0} in
5) ;;
*) die "${ECLASS}.eclass: API in EAPI ${EAPI} not yet established"
esac
# @FUNCTION: _s6_get_servicedir
# @INTERNAL
# @DESCRIPTION:
# Get unprefixed servicedir.
_s6_get_servicedir() {
echo /var/svc.d
}
# @FUNCTION: s6_get_servicedir
# @DESCRIPTION:
# Output the path for the s6 service directory (not including ${D}).
s6_get_servicedir() {
debug-print-function ${FUNCNAME} "${@}"
echo "${EPREFIX}$(_s6_get_servicedir)"
}
# @FUNCTION: s6_install_service
# @USAGE: servicename run finish
# @DESCRIPTION:
# Install an s6 service.
# servicename is the name of the service.
# run is the run script for the service.
# finish is the optional finish script for the service.
s6_install_service() {
debug-print-function ${FUNCNAME} "${@}"
local name="$1"
local run="$2"
local finish="$3"
[[ $name ]] ||
die "${ECLASS}.eclass: you must specify the s6 service name"
[[ $run ]] ||
die "${ECLASS}.eclass: you must specify the s6 service run script"
(
local servicepath="$(_s6_get_servicedir)/$name"
exeinto "$servicepath"
newexe "$run" run
[[ $finish ]] && newexe "$finish" finish
)
}
# @FUNCTION: s6_service_down
# @USAGE: servicename
# @DESCRIPTION:
# Install the "down" flag so this service will not be started by
# default.
# servicename is the name of the service.
s6_service_down() {
debug-print-function ${FUNCNAME} "${@}"
local name="$1"
[[ $name ]] ||
die "${ECLASS}.eclass: you must specify the s6 service name"
(
touch "$T"/down || die
local servicepath="$(_s6_get_servicedir)/$name"
insinto "$servicepath"
doins "$T"/down
)
}
# @FUNCTION: s6_service_nosetsid
# @USAGE: servicename
# @DESCRIPTION:
# Install the "nosetsid" flag so this service will not be made a session
# leader.
# servicename is the name of the service.
s6_service_nosetsid() {
debug-print-function ${FUNCNAME} "${@}"
local name="$1"
[[ $name ]] ||
die "${ECLASS}.eclass: you must specify the s6 service name"
(
touch "$T"/nosetsid || die
local servicepath="$(_s6_get_servicedir)/$name"
insinto "$servicepath"
doins "$T"/nosetsid
)
}
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [gentoo-dev] s6.eclass: new eclass for installing s6 services
2015-06-02 15:08 ` William Hubbs
@ 2015-06-02 21:10 ` William Hubbs
0 siblings, 0 replies; 9+ messages in thread
From: William Hubbs @ 2015-06-02 21:10 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 75 bytes --]
This was committed just now since there was no further feedback.
William
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-06-02 21:10 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01 17:13 [gentoo-dev] s6.eclass: new eclass for installing s6 services William Hubbs
2015-06-01 17:24 ` Michał Górny
2015-06-01 17:30 ` William Hubbs
2015-06-01 17:39 ` Brian Evans
2015-06-01 18:24 ` William Hubbs
2015-06-01 21:08 ` William Hubbs
2015-06-01 21:14 ` Tim Harder
2015-06-02 15:08 ` William Hubbs
2015-06-02 21:10 ` William Hubbs
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox