Tom Willemse
2313102c2b
‘current-filename’ is the real file name of the file, not the symbolic link that it's accessed through, so any relative references will be wrong.
1.3 KiB
1.3 KiB
The Shepherd manual suggests that you use a single init.scm
, but as is pointed out by this article about GNU Shepherd user services it might be better to have the services in separate files so you can restart them individually if you make any changes to them. So I just put a loading script into init.scm
that goes through the init.d
directory and loads each service defined in there.
(use-modules (shepherd service)
((ice-9 ftw) #:select (scandir)))
I can't use (current-filename)
here because this file will be symlinked into the $XDG_CONFIG_DIR/shepherd/init.scm
and the current-filename
function will return the actual path, not the path of the symbolic link.
(define init-directory
(string-append (getenv "XDG_CONFIG_HOME") "/shepherd/init.d"))
With that in place, we can loop over each *.scm
file in the init-directory
and load them.
(for-each
(λ (file) (load (string-append "init.d/" file)))
(scandir init-directory
(λ (file) (string-suffix? ".scm" file))))
Now turn shepherd into a daemon.
(action 'shepherd 'daemonize)