diff options
author | Oscar Najera <hi@oscarnajera.com> | 2024-12-21 12:30:38 +0100 |
---|---|---|
committer | Oscar Najera <hi@oscarnajera.com> | 2024-12-21 12:30:38 +0100 |
commit | f7193ea090891532ec5e6f2abbd6f805bdfbbf1f (patch) | |
tree | ae3b74fdf024e2e67bd63ddb3a560ca3d1a5331a /config/shepherd | |
parent | 1979a19feb55dae81710ac5c00802e39f69365bf (diff) | |
download | dotfiles-f7193ea090891532ec5e6f2abbd6f805bdfbbf1f.tar.gz dotfiles-f7193ea090891532ec5e6f2abbd6f805bdfbbf1f.tar.bz2 dotfiles-f7193ea090891532ec5e6f2abbd6f805bdfbbf1f.zip |
update to shepherd 1.0
Diffstat (limited to 'config/shepherd')
-rw-r--r-- | config/shepherd/init.d/bitcoin.scm | 82 | ||||
-rw-r--r-- | config/shepherd/init.d/cardano.scm | 45 | ||||
-rw-r--r-- | config/shepherd/init.d/cmk.scm | 9 | ||||
-rw-r--r-- | config/shepherd/init.d/my-daemons.scm | 45 | ||||
-rw-r--r-- | config/shepherd/init.scm | 19 |
5 files changed, 85 insertions, 115 deletions
diff --git a/config/shepherd/init.d/bitcoin.scm b/config/shepherd/init.d/bitcoin.scm index 2805b57..a010bb4 100644 --- a/config/shepherd/init.d/bitcoin.scm +++ b/config/shepherd/init.d/bitcoin.scm @@ -2,11 +2,6 @@ (use-modules (ice-9 popen) (ice-9 rdelim)) -(define (make-dir-parents dir-path) - (unless (access? dir-path F_OK) - (make-dir-parents (dirname dir-path)) - (mkdir dir-path))) - (define (bitcoin-rpc-pass) (let* ((port (open-input-pipe @@ -18,44 +13,49 @@ ;; TESTNET ;; Requires the running node which is now under systemd (register-services - (make <service> - #:docstring "Bitcoin testnet index" - #:provides '(index-testnet) - #:start (make-forkexec-constructor - (list "/home/titan/dev/bitcoin/rust-bitcoin-indexer/target/release/bitcoin-indexer") - #:environment-variables `("DATABASE_URL=postgres://titan@%2Frun%2Fpostgresql/btc-testnet-idx" - ,(format #f "NODE_RPC_URL=http://crazy:~a@127.0.0.1:18332/" (bitcoin-rpc-pass)) - "RUST_LOG=bitcoin_indexer=info") - #:log-file "/tmp/btc-indexer.log") - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) + (service + '(index-testnet) + #:documentation "Bitcoin testnet index" + #:start (make-forkexec-constructor + (list "/home/titan/dev/bitcoin/rust-bitcoin-indexer/target/release/bitcoin-indexer") + #:environment-variables `("DATABASE_URL=postgres://titan@%2Frun%2Fpostgresql/btc-testnet-idx" + ,(format #f "NODE_RPC_URL=http://crazy:~a@127.0.0.1:18332/" (bitcoin-rpc-pass)) + "RUST_LOG=bitcoin_indexer=info") + #:log-file "/tmp/btc-indexer.log") + #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C + #:respawn? #t)) (register-services - (make <service> - #:docstring "Bitcoin testnet lnd lightning" - #:provides '(lnd-testnet) - #:start (make-forkexec-constructor - (list "/home/titan/.local/bin/lnd" - "--lnddir=/run/media/titan/ext_backup/personal/bitcoin/lnd/" - "--noseedbackup")) - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) + (service + '(lnd-testnet) + #:documentation "Bitcoin testnet lnd lightning" + #:start (make-forkexec-constructor + (list "/home/titan/.local/bin/lnd" + "--lnddir=/run/media/titan/ext_backup/personal/bitcoin/lnd/" + "--noseedbackup")) + #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C + #:respawn? #t)) ;; ssh (register-services - (make <service> - #:docstring "Sarah ssh tunnel" - #:provides '(sarah-ssh) - #:start (make-forkexec-constructor - (list "ssh" "-NTv" - "-o" "ServerAliveInterval=60" - "-o" "ExitOnForwardFailure=yes" - "-o" "StreamLocalBindUnlink=yes" - "-L" "8335:localhost:8332" ;; btcm - "-L" "18335:localhost:18332" ;; btct - "-L" "8481:localhost:8480" ;; LNDT - "orchest@sarah") - #:log-file "/tmp/sarah-ssh.log" - #:environment-variables '("SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh")) - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) + (service + '(nina-ssh) + #:documentation "nina ssh tunnel" + #:start (make-forkexec-constructor + (list "ssh" "-NTv" + "-o" "ServerAliveInterval=60" + "-o" "ExitOnForwardFailure=yes" + "-o" "StreamLocalBindUnlink=yes" + "-L" "8335:localhost:8332" ;; btcm + "-L" "18335:localhost:18332" ;; btct + "-L" "8481:localhost:8480" ;; LNDT + ;; "-L" "/tmp/nina-mn.socket:/run/cardano-node-mainnet/socket" + ;; "-L" "/tmp/nina-pr.socket:/run/cardano-node-preview/socket" + ;; "-L" "54320:localhost:5432" + ;; "-L" "50001:localhost:50001" ;; electrs + ;; "-L" "24224:localhost:24224" ;; electrs monitoring + "orchest@nina") + #:log-file "/tmp/nina-ssh.log" + #:environment-variables '("SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh")) + #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C + #:respawn? #t)) diff --git a/config/shepherd/init.d/cardano.scm b/config/shepherd/init.d/cardano.scm index 1c5b731..1fc1d6f 100644 --- a/config/shepherd/init.d/cardano.scm +++ b/config/shepherd/init.d/cardano.scm @@ -1,33 +1,9 @@ - -(define (make-dir-parents dir-path) - (unless (access? dir-path F_OK) - (make-dir-parents (dirname dir-path)) - (mkdir dir-path))) - (register-services - (make <service> - #:docstring "Nina ssh tunnel, Cardano nodes" - #:provides '(nina-ssh) - #:start (make-forkexec-constructor - (list "ssh" "-NTv" - "-o" "ServerAliveInterval=60" - "-o" "ExitOnForwardFailure=yes" - "-o" "StreamLocalBindUnlink=yes" - "-L" "/tmp/nina-mn.socket:/run/cardano-node-mainnet/socket" - "-L" "/tmp/nina-pr.socket:/run/cardano-node-preview/socket" - "-L" "54320:localhost:5432" - "-L" "50001:localhost:50001" ;; electrs - "-L" "24224:localhost:24224" ;; electrs monitoring - "cardano@nina") - #:log-file "/tmp/nina-ssh.log" - #:environment-variables '("SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh")) - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) + (list -(register-services - (make <service> - #:docstring "Cardano preview wallet" - #:provides '(preview-wallet) + (service + '(preview-wallet) + #:documentation "Cardano preview wallet" #:start (make-forkexec-constructor (list "cardano-wallet" ;;(string-append (getenv "HOME") "/.cabal/bin/cardano-wallet") @@ -39,12 +15,11 @@ #:log-file (string-append (getenv "HOME") "/test-cardano/preview/log/wallet.log")) #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:requires '(nina-ssh))) + #:requirement '(nina-ssh)) -(register-services - (make <service> - #:docstring "Mainnet wallet" - #:provides '(mainnet-wallet) + (service + '(mainnet-wallet) + #:documentation "Mainnet wallet" #:start (make-forkexec-constructor (list ;;(string-append (getenv "HOME") "/.cabal/bin/cardano-wallet") "cardano-wallet" @@ -53,5 +28,5 @@ "--database" (string-append (getenv "HOME") "/test-cardano/main/wallet") "--mainnet") #:log-file (string-append (getenv "HOME") "/test-cardano/main/log/wallet.log")) - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:requires '())) + ;; 2 is SIGINT - interupt process stream, ctrl-C + #:stop (make-kill-destructor 2)))) diff --git a/config/shepherd/init.d/cmk.scm b/config/shepherd/init.d/cmk.scm index 07f32d4..20f7785 100644 --- a/config/shepherd/init.d/cmk.scm +++ b/config/shepherd/init.d/cmk.scm @@ -1,7 +1,8 @@ (register-services - (make <service> - #:docstring "SSH tunnel to ingrid CMK server for socket" - #:provides '(ingrid-cmk) + (list + (service + '(ingrid-cmk) + #:documentation "SSH tunnel to ingrid CMK server for socket" #:start (make-forkexec-constructor (list "ssh" "-NTv" "-o" "ServerAliveInterval=60" @@ -12,4 +13,4 @@ #:log-file "/tmp/ingrid-cmk.log" #:environment-variables '("SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh")) #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) + #:respawn? #t))) diff --git a/config/shepherd/init.d/my-daemons.scm b/config/shepherd/init.d/my-daemons.scm index 1b5daf8..c235bfd 100644 --- a/config/shepherd/init.d/my-daemons.scm +++ b/config/shepherd/init.d/my-daemons.scm @@ -1,27 +1,26 @@ - -(register-services - (make <service> - #:docstring "Habit tracker" - #:provides '(habit-logs) - #:start (make-forkexec-constructor - (list "sbcl" - "--load" - (string-append (getenv "HOME") "/dev/common-lisp/todo-demo/habit.asd") - "--eval" "(asdf:load-system :habit)" - "--eval" "(habit-log::main)" - "--non-interactive") - #:directory (string-append (getenv "HOME") "/dev/common-lisp/todo-demo/") - #:environment-variables (list (string-append "HABIT_DIR=" (getenv "HOME") "/org/habits/") - "PORT=4242") - #:log-file "/tmp/habits.log") - #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t)) - (let ((workdir (string-append (getenv "HOME") "/dev/dotfiles/scratch/semgrep/"))) (register-services - (make <service> - #:docstring "Roam semantic DB" - #:provides '(roam-semantic-db) + (list + (service + '(habit-logs) + #:documentation "Habit tracker" + #:start (make-forkexec-constructor + (list "sbcl" + "--load" + (string-append (getenv "HOME") "/dev/common-lisp/todo-demo/habit.asd") + "--eval" "(asdf:load-system :habit)" + "--eval" "(habit-log::main)" + "--non-interactive") + #:directory (string-append (getenv "HOME") "/dev/common-lisp/todo-demo/") + #:environment-variables (list (string-append "HABIT_DIR=" (getenv "HOME") "/org/habits/") + "PORT=4242") + #:log-file "/tmp/habits.log") + #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interu pt process stream, ctrl-C + #:respawn? #t) + + (service + '(roam-semantic-db) + #:documentation "Roam semantic DB" #:start (make-forkexec-constructor (list "python" (string-append workdir "server.py")) @@ -29,4 +28,4 @@ #:environment-variables (list (string-append "PATH=" (getenv "HOME") "/.virtualenvs/language/bin")) #:log-file "/tmp/roam-semantic.log") #:stop (make-kill-destructor 2) ;; 2 is SIGINT - interupt process stream, ctrl-C - #:respawn? #t))) + #:respawn? #t)))) diff --git a/config/shepherd/init.scm b/config/shepherd/init.scm index 3d47bd4..6b16623 100644 --- a/config/shepherd/init.scm +++ b/config/shepherd/init.scm @@ -1,25 +1,20 @@ ;; init.scm -- default shepherd configuration file. (use-modules ((ice-9 ftw) #:select (scandir)) + (shepherd service) (srfi srfi-26)) ;; Load all the files in the directory 'init.d' with a suffix '.scm'. (for-each - (lambda (file) - (load (string-append "init.d/" file))) - (scandir (string-append (dirname (current-filename)) "/init.d") - (cut string-suffix? ".scm" <>))) - - -;; Services known to shepherd: -;; Add new services (defined using 'make <service>') to shepherd here by -;; providing them as arguments to 'register-services'. -(register-services) + (lambda (file) + (load (string-append "init.d/" file))) + (scandir (string-append (dirname (current-filename)) "/init.d") + (cut string-suffix? ".scm" <>))) ;; Send shepherd into the background -(action 'shepherd 'daemonize) +(perform-service-action root-service 'daemonize) ;; Services to start when shepherd starts: ;; Add the name of each service that should be started to the list ;; below passed to 'for-each'. -(for-each start '(habit-logs roam-semantic-db)) +(start-in-the-background '(habit-logs roam-semantic-db)) |