Paste number 349846: shepherd init.scm

Paste number 349846: shepherd init.scm
Pasted by: lfam
When:5 years, 2 months ago
Share:Tweet this! | http://paste.lisp.org/+7HXY
Channel:None
Paste contents:
Raw Source | XML | Display As
;; To use this automatically, add something like the following line to
;; whatever gets sourced for a login shell:
;;
;; [[ -z $(pgrep -U $(id --user) shepherd) ]] && shepherd & > /dev/null
;;
;; Or, just invoke `shepherd`.

(use-modules (ice-9 match)
             (srfi srfi-1)
             (system repl server))

(define (touch-file file)
  (close-port (open-file file "a0b")))

(register-services

  (make <service>
    #:provides '(mpd)
    #:requires '()
    #:start (lambda args
              (define (scope file)
                (string-append (getenv "HOME") "/.mpd/" file))

              (unless (file-exists? (scope "playlists"))
                (mkdir (scope "playlists")))
              (touch-file (scope "database"))
;              (make-forkexec-constructor
              (fork+exec-command
               (list "mpd" "--no-daemon")))
    #:stop (make-kill-destructor))

;  (make <service>
;    #:provides '(cron)
;    #:requires '()
;    #:start (make-forkexec-constructor '("mcron")))

  (make <service>
    #:provides '(syncthing)
    #:requires '()
    #:start (make-forkexec-constructor '("syncthing"
                                         "-no-restart"
                                         "-no-browser"))
    #:stop (make-kill-destructor)))

(action 'shepherd 'daemonize)

(for-each start '(mpd syncthing))

This paste has no annotations.

Colorize as:
Show Line Numbers

Lisppaste pastes can be made by anyone at any time. Imagine a fearsomely comprehensive disclaimer of liability. Now fear, comprehensively.