Bug 237760

Summary: sysutils/s6-rc: Allow overriding livedir
Product: Ports & Packages Reporter: dewayne
Component: Individual Port(s)Assignee: Alexey Dokuchaev <danfe>
Status: Closed FIXED    
Severity: Affects Some People CC: crest, danfe, moo
Priority: --- Keywords: needs-patch, needs-qa
Version: LatestFlags: bugzilla: maintainer-feedback? (moo)
Hardware: Any   
OS: Any   

Description dewayne 2019-05-06 02:00:19 UTC
Would it be possible to add a variable to the Makefile that enables customisation of s6-rc's root. I have different location of memory disks and would prefer to pass a variable during build rather than have to create a soft-link to /run/s6-rc.

Perhaps something like:

--- /usr/ports/sysutils/s6-rc/Makefile  (revision 500571)
+++ /usr/ports/sysutils/s6-rc/Makefile  (working copy)
@@ -21,6 +21,8 @@
 LIB_DEPENDS=   libs6.so:sysutils/s6 \
                libskarnet.so:devel/skalibs

+LIVEDIR?=/run/s6-rc
+
 USES=          gmake

 USE_LDCONFIG=  yes
@@ -31,6 +33,7 @@
        --with-lib=${LOCALBASE}/lib/execline \
        --with-lib=${LOCALBASE}/lib/s6 \
        --with-dynlib=${LOCALBASE}/lib \
+       --livedir=${LIVEDIR} \
        --enable-shared

 DOCS=          AUTHORS COPYING INSTALL README doc/*.html

And thanks for maintaining the port, I found s6 & friends and decided to use it  before realising that it was already available in "ports".  A nice surprise :)
Comment 1 Kubilay Kocak freebsd_committer freebsd_triage 2019-05-06 02:06:07 UTC
@Dewayne Could you include your proposed change as an attachment please.

Also, what does the livedir default to, if not specified at buildtime? If it doesn't default to it already, it should probably be default to "/var/run"

Does the software have a configuration file? Is a sample configuration provided by the port/package? If so, complementary changes should be added there too, setting the default location to match the build-time path
Comment 2 dewayne 2019-05-06 08:43:17 UTC
(In reply to Kubilay Kocak from comment #1)
Unfortunately the samba jail is having some problems, so I'm unable to access the diff file.  If it was more than two lines...

The default can be overridden at build time, or tediously at each command invocation.  The "livedir" is stated as /run/s6-rc in the documentation, refer http://www.skarnet.org/software/s6-rc/s6-rc-db.html

I like your integrative thinking, but unfortunately there is no configuration file, and hence no sample config.  The port performs a function akin to openrc - in that you define what the system/server is going to do.  This provides a reasonable explanation
http://www.skarnet.org/software/s6-rc/why.html

Alas, even with excellent documentation it is a steep learning curve, where examples would be highly beneficial.
Comment 3 dewayne 2019-05-06 09:19:57 UTC
(In reply to Kubilay Kocak from comment #1)
Oops - I missed a question.

Defaulting to /var/run wouldn't be the best idea.  As the s6-rc system requires four directory trees to function ( source files; compiledir; livedir; scandir), comprising:
1. Your source files, I've placed mine in /usr/local/etc/s6 
2. A target directory for the "compiled" source files is created (as an argument to the s6-rc-compile program).  Compiled in the sense that the source files are scanned for things like application dependencies, bundles of applications, etc, and the supporting "scandirectory" describes this architecture.
3. Upon initialisation, the compiled tree is copied to the "livedir" where setting some configuration files (essentially saying applications are down ie "not started")
4. The essence of service management is performed by the s6 port which manages the service supervisors via the final "scandir" - its essentially a bunch of softlinks to livedir.  

Once this is done, the serivces are managed by signal interrupts and its actually a lot of fun.  The buik of the work is in constructing the scripts to run and finish or crash things. 

So putting this into /var/run may not be the best, /var/db may be better but I took the approach of creating a  mfs (from fstab) rw,noatime,async,-s10m,-b8192,-f2048,-S,-n where I place the compiledir, livedir and scandir.  Which works very well, there are many small files here (and may be frequently accessed).

The one change to the s6-rc/Makefile that I'd suggest is to use /usr/local/etc/s6 as the FreeBSD way of storing what are essentially config files that describe how to run/finish/contents/type/...  things to the system.  Unfortunately there is no configuration option in the s6-rc distribution, so creating such a directory could be included in the Makefile.

I hope that this helps.
Comment 4 crest 2020-04-17 12:15:08 UTC
You can pass the live directory on the command line unless some wrapper script doesn't allow you to pass `-l $live_dir` to s6-rc there is not need to use (or change) the default live directory except ease of use on the shell. If any scripts are lacking a way to pass the live directory path through those scripts should be improved.
Comment 5 dewayne 2020-04-17 12:26:37 UTC
(In reply to crest from comment #4)
Sure.  But its more about the tedium of needing to be explicit to s6-rc everytime  that it is interacted with.  It is a lot more efficient making use of a 
LIVEDIR?= whatever
in the build, then to enter it "-l whatever" for every command.
Comment 6 crest 2020-05-01 14:22:46 UTC
I took over as maintainer of s6-rc and see no problem adding the feature you requested. Please attach a patch for me to review to this PR.
Comment 7 commit-hook freebsd_committer freebsd_triage 2021-05-09 09:01:52 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=862f5d1238e0075bee9492ee6e65fc0098b7f1f7

commit 862f5d1238e0075bee9492ee6e65fc0098b7f1f7
Author:     Alexey Dokuchaev <danfe@FreeBSD.org>
AuthorDate: 2021-05-09 08:56:26 +0000
Commit:     Alexey Dokuchaev <danfe@FreeBSD.org>
CommitDate: 2021-05-09 08:58:59 +0000

    - Update Skarnet.org software stack ports to their latest versions
    - Allow to override default location of s6-rc's root (--livedir)

    PR:     237760

 devel/skalibs/Makefile   | 2 +-
 devel/skalibs/distinfo   | 6 +++---
 devel/skalibs/pkg-plist  | 2 +-
 lang/execline/Makefile   | 2 +-
 lang/execline/distinfo   | 6 +++---
 lang/execline/pkg-plist  | 4 ++--
 sysutils/s6-rc/Makefile  | 5 ++++-
 sysutils/s6-rc/distinfo  | 6 +++---
 sysutils/s6-rc/pkg-plist | 2 +-
 sysutils/s6/Makefile     | 2 +-
 sysutils/s6/distinfo     | 6 +++---
 sysutils/s6/pkg-plist    | 2 +-
 12 files changed, 24 insertions(+), 21 deletions(-)
Comment 8 Alexey Dokuchaev freebsd_committer freebsd_triage 2021-05-09 14:15:49 UTC
Passing --livedir during the build (configure, really) looks least intrusive, so I went ahead with that suggestion.  The only change I took liberty to make is the default value of LIVEDIR being /var/run/s6-rc rather than /run/s6-rc as /run is not part of hier(7).
Comment 9 crest 2021-09-06 18:41:49 UTC
Which did break existing deployments.