aboutsummaryrefslogtreecommitdiff
path: root/shepherd/init.scm
blob: 232af4a565f33f1271820ff84524d6d60a4a5e99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
(use-modules (shepherd service))

(define date+%s
  (strftime "%s" (gmtime (current-time))))

(define bnw
  (make <service>
	#:provides '(bnw)
	#:docstring "Run the Beyesian Network Webserver"
	#:start (make-forkexec-constructor
		  '("/usr/bin/sudo" "/home/shepherd/run_bnw.sh")
		  #:log-file (string-append "/home/shepherd/logs/bnw-"
					    date+%s ".log"))
	#:stop (make-kill-destructor)
	#:respawn? #t))
(register-services bnw)

(define gitea
  (make <service>
	#:provides '(gitea)
	#:docstring "Run a Gitea instance"
	#:start (make-forkexec-constructor
		  '("/usr/bin/sudo" "/home/shepherd/run_gitea.sh")
		  #:log-file (string-append "/home/shepherd/logs/gitea-"
					    date+%s ".log"))
	#:stop (make-kill-destructor)
	#:respawn? #t))
(register-services gitea)

(define ipfs
  (make <service>
	#:provides '(ipfs)
	#:docstring "Run the IPFS daemon"
	#:start (make-forkexec-constructor
		  '("/usr/bin/sudo" "/home/shepherd/run_ipfs.sh")
		  #:log-file (string-append "/home/shepherd/logs/ipfs-"
					    date+%s ".log"))
	#:stop (make-kill-destructor)
	#:respawn? #t))
(register-services ipfs)

(define mcron
  (make <service>
	#:provides '(mcron)
	#:docstring "Run the mcron daemon"
	#:start (make-forkexec-constructor
		  '("/var/guix/profiles/per-user/shepherd/guix-profile/bin/mcron")
		  #:log-file (string-append "/home/shepherd/logs/mcron-"
					    date+%s ".log"))
	#:stop (make-kill-destructor)
	#:respawn? #t))
(register-services mcron)

(define power
  (make <service>
	#:provides '(power)
	#:docstring "Run the BXD Power Calculator app"
	#:start (make-forkexec-constructor
		  ;'(system* "/var/guix/profiles/per-user/shepherd/current-guix/bin/guix" "environment" "--ad-hoc" "rn6-assembly-error-app" "--" "/bin/sh -c 'R_LIBS_USER=$GUIX_ENVIRONMENT/site-library/ rn6-assembly-error-app'")
		  '("/home/shepherd/run_power.sh")
		  #:log-file (string-append "/home/shepherd/logs/power-"
					    date+%s ".log"))
	#:stop (make-kill-destructor)
	#:respawn? #t))
(register-services power)

(define rn6app
  (make <service>
	#:provides '(rn6app)
	#:docstring "Run RN6 Assembly Error app"
	#:start (make-forkexec-constructor
		  ;'(system* "/var/guix/profiles/per-user/shepherd/current-guix/bin/guix" "environment" "--ad-hoc" "rn6-assembly-error-app" "--" "/bin/sh -c 'R_LIBS_USER=$GUIX_ENVIRONMENT/site-library/ rn6-assembly-error-app'")
		  '("/home/shepherd/run_rn6app.sh")
		  #:log-file (string-append "/home/shepherd/logs/rn6app-"
					    date+%s ".log"))
	#:stop (make-kill-destructor)
	#:respawn? #t))
(register-services rn6app)

(define test-upgrade
  (make <service>
	#:provides '(test-upgrade)
	#:docstring "Build all the services to make sure they work on an upgrade"
	#:start (make-forkexec-constructor
		  (when (zero? (system* "guix" "build" "-L" "/home/shepherd/guix-bioinformatics"
					"--no-grafts" "bnw" "gitea" "go-ipfs" "edirect-gn"
					"bxd-power-calculator-app" "rn6-assembly-error-app"))
		    (zero? (system* "guix" "system" "-L" "/home/shepherd/guix-bioinformatics"
				    "container" "/home/shepherd/guix-bioinformatics/gn/services/bnw-container.scm"
				    "--share=/home/shepherd/logs/bnw-server=/var/log" "--network")))
		  #:log-file (string-append "/home/shepherd/logs/test-upgrade-"
					    date+%s ".log"))
	#:one-shot? #t))
(register-services test-upgrade)

;; Send shepherd into the background
(action 'shepherd '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 '(bnw gitea ipfs mcron power rn6app))