Re: shepherd, default /etc/shepherd.scm for other distributions
On Tue, Apr 12, 2016 at 7:52 AM, Jean Louiswrote: > I am searching for a sample shepherd /etc/shepherd.scm to be run on > other distributions. If anyone has such file, just a sample, for one > service, with the recent shepherd version, let me know. It would be > enough If you just want to see a harebrained example, this is what I am currently using with non-Guix Shepherd version 0.3.1 (warning: on Hurd). It basically attempts to reproduce the system initialization shell script from upstream Hurd, with a few ideas from other init systems mixed into it. http://paste.fedoraproject.org/354821/14604969/ It reads its service definitions from a drop-in configuration directory that packages can write into when they're installed. Here are the contents of a few of those files. http://paste.fedoraproject.org/354822/97563146/ David
[PATCH shepherd v2] support: Ignore errors in mkdir-p when the directories exist.
* modules/shepherd/support.scm (mkdir-p): Don't throw errors when mkdir fails but the directory exists afterwards. --- modules/shepherd/support.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm index 9bc5f5d..4059770 100644 --- a/modules/shepherd/support.scm +++ b/modules/shepherd/support.scm @@ -172,7 +172,8 @@ output port, and PROC's result is returned." (mkdir path)) (loop tail path)) (lambda args - (if (= EEXIST (system-error-errno args)) + (if (and (file-exists? path) + (eq? (stat:type (stat path)) 'directory)) (loop tail path) (apply throw args)) (() #t -- 2.5.0
[PATCH shepherd] support: Ignore errors on parent directories in mkdir-p.
* modules/shepherd/support.scm (mkdir-p): Don't throw errors when mkdir fails and there are more subdirectory components to try. --- Hi, My use case for this is that I have a crazy Hurd setup that boots a read-only root file system with a passive tmpfs translator on /run. When mkdir-p runs with "/run/shepherd", it tries to mkdir "/run". On Hurd, mkdir first tests for a read-only file system, so mkdir-p catches and throws EROFS instead of catching and ignoring EEXIST. The init process then dies when it tries to stat the non-existent /run/shepherd. This patch ignores all errors from parent directories, assuming we only really care about the status of creating the final path component. Another possibility could be to try to change Hurd's error ordering instead, but it seems to be acceptably standard behavior: If more than one error occurs in processing a function call, any one of the possible errors may be returned, as the order of detection is undefined.[0] Can this be applied, or do you prefer another option? Thanks. David [0] http://pubs.opengroup.org/onlinepubs/009695399/functions/xsh_chap02_03.html modules/shepherd/support.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/shepherd/support.scm b/modules/shepherd/support.scm index 9bc5f5d..3106212 100644 --- a/modules/shepherd/support.scm +++ b/modules/shepherd/support.scm @@ -172,7 +172,7 @@ output port, and PROC's result is returned." (mkdir path)) (loop tail path)) (lambda args - (if (= EEXIST (system-error-errno args)) + (if (or (not (null? tail)) (= EEXIST (system-error-errno args))) (loop tail path) (apply throw args)) (() #t -- 2.5.0
Re: [PATCH] dmd: Allow storing early logs before writing to disk
On Sat, Sep 13, 2014 at 8:16 AM, Ludovic Courtès l...@gnu.org wrote: David Michael fedora@gmail.com skribis: On Thu, Sep 11, 2014 at 10:31 AM, Ludovic Courtès l...@gnu.org wrote: [snip] The ideal thing would be: 1. Run ‘dmd -l foo.log’. 2. If foo.log is not writable, then make ‘log-output-port’ a string port. Do you think it makes sense to define log-output-port as a string port at first instead of a void port? No, because running dmd without ‘-l’ means disabling logging altogether, hence the void port. That doesn't appear to be the case. The main procedure in modules/dmd.scm is calling start-logging unconditionally, with the default log file if the option is omitted. 3. When foo.log becomes writable, have ‘log-output-port’ point to it and dump previously buffered data. But #3 is difficult. Maybe instead of using a string port, we could use a string port that keeps trying to open the log file? It would be best to use inotify (or the Hurd’s fs_notify), of course. Something like that would be a nice transparent solution for read-only booting, but I could see another issue arising from it later. It's common to have /var or /var/log on a different volume that may not be mounted when the root file system's /var/log is writable. Writing logs as soon as possible could miss the sysadmin's desired log volume (which theoretically could also happen with dmd as is). Right, that makes sense. I think it’s a good argument against trying to do something too smart. So probably the patch you propose is the best approach. Then I would suggest a small change: instead of the magic ‘--log-file=delayed’, what about adding a new option, say, ‘--buffered-log’? WDYT? Yes, I think a separate option would be better. If it's expected that users will handle early mount configuration in their dmdconf.scm, separate options could allow doing something like specifying both options and starting to write to the given log file automatically after processing dmdconf.scm, if it wasn't started explicitly. That could at least remove the need for the user to have to know to start logging themselves. I haven't had a chance to try rewriting this yet, but I can send a new version when I do. Thanks. David
[PATCH] dmd: Allow storing early logs before writing to disk
* modules/dmd.scm (main): Start logging to a buffer instead of a file when the logfile option is set to delayed. * modules/dmd/comm.scm (start-logging-to-buffer): New procedure. (start-logging): If logs were being written to a string port, write its contents to the log file. --- Hi, When using dmd to bring up a read-only file system, it will quit when it fails to open a log file for writing. This is a proof-of-concept patch that adds the option to start writing logs to a string port. It allows having a dmdconf.scm that runs fsck, makes the disk writable, and then starts writing past and future log messages to disk with (start-logging /var/log/dmd.log). Does anyone have any thoughts on this? Is there a better way to handle this case? Thanks. David modules/dmd.scm | 7 +-- modules/dmd/comm.scm | 17 ++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/modules/dmd.scm b/modules/dmd.scm index cf72d7a..e0f69c7 100644 --- a/modules/dmd.scm +++ b/modules/dmd.scm @@ -97,7 +97,8 @@ (make option #:long logfile #:short #\l #:takes-arg? #t #:optional-arg? #f #:arg-name FILE - #:description log actions in FILE + #:description + log actions in FILE or to a buffer if FILE is \delayed\ #:action (lambda (file) (set! logfile file))) (make option @@ -137,7 +138,9 @@ (and socket-file (verify-dir (dirname socket-file) insecure)) ;; Enable logging as first action. -(start-logging logfile) +(if (string-ci=? logfile delayed) + (start-logging-to-buffer) + (start-logging logfile)) ;; Send output to log and clients. (set-current-output-port dmd-output-port) diff --git a/modules/dmd/comm.scm b/modules/dmd/comm.scm index fb08629..aeb45ca 100644 --- a/modules/dmd/comm.scm +++ b/modules/dmd/comm.scm @@ -37,6 +37,7 @@ read-command start-logging +start-logging-to-buffer stop-logging %current-client-socket dmd-output-port)) @@ -103,10 +104,20 @@ return the socket. ;; Port for logging. This must always be a valid port, never `#f'. (define log-output-port (%make-void-port w)) (define (start-logging file) - (let ((directory (dirname file))) + (let ((directory (dirname file)) (oldport log-output-port)) (unless (file-exists? directory) - (mkdir directory))) - (set! log-output-port (open-file file al))) ; line-buffered port + (mkdir directory)) +(set! log-output-port (open-file file al)) ; line-buffered port +;; Attempt to dump any buffered log data to the given log file. This only +;; succeeds if log-output-port was an open output string port, as verified +;; by get-output-string. Otherwise, logging to a file is started normally. +(catch #t + (lambda () +(display (get-output-string oldport) log-output-port) +(close-output-port oldport)) + noop))) +(define (start-logging-to-buffer) + (set! log-output-port (open-output-string))) (define (stop-logging) (close-port log-output-port) (set! log-output-port (%make-void-port w))) -- 1.9.3
[PATCH] dmd: Support cross-compilation
* Makefile.am (%.go): Specify the target platform. --- Hi, Configuring different build and host platforms could result in guile object files for the wrong CPU architecture. Can something like this set the target for guild? Thanks. David Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 3329382..8e075bc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -115,7 +115,8 @@ modules/dmd/config.scm: modules/dmd/config.scm.in Makefile %.go: %.scm $(templates:%.in=%) $(MKDIR_P) `dirname $@` LC_ALL=C\ - $(GUILD) compile -L $(top_builddir)/modules \ + $(GUILD) compile --target=$(host) \ + -L $(top_builddir)/modules \ -L $(top_srcdir)/modules\ -Wformat -Wunbound-variable -Warity-mismatch \ -o $@ $ -- 1.9.3