blob: 91ac166beb274347fd97ef3bdb17ceb427e7cdcb (
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
(define-module (gn services databases)
#:use-module (gnu)
#:use-module (gnu packages admin)
#:use-module (gnu packages databases)
#:use-module (gnu services configuration)
#:use-module (gnu services shepherd)
#:use-module (guix packages)
#:use-module (guix records)
#:export (virtuoso-configuration
virtuoso-configuration?
virtuoso-configuration-package
virtuoso-configuration-state-directory
virtuoso-configuration-server-ip
virtuoso-configuration-server-port
virtuoso-configuration-number-of-buffers
virtuoso-configuration-maximum-dirty-buffers
virtuoso-configuration-http-server-ip
virtuoso-configuration-http-server-port
virtuoso-service-type))
;;;
;;; Virtuoso
;;;
(define-record-type* <virtuoso-configuration>
virtuoso-configuration make-virtuoso-configuration
virtuoso-configuration?
(package virtuoso-configuration-package
(default virtuoso-ose))
(state-directory virtuoso-configuration-state-directory
(default "/var/lib/virtuoso"))
(server-ip virtuoso-configuration-server-ip
(default "localhost"))
(server-port virtuoso-configuration-server-port
(default 1111))
(dirs-allowed virtuoso-dirs-allowed
(default "/var/genenetwork/virtuoso-data"))
(number-of-buffers virtuoso-configuration-number-of-buffers
(default #f))
(maximum-dirty-buffers virtuoso-configuration-maximum-dirty-buffers
(default #f))
(http-server-ip virtuoso-configuration-http-server-ip
(default "localhost"))
(http-server-port virtuoso-configuration-http-server-port
(default 8890))
(checkpoint-interval virtuoso-configuration-checkpoint-interval
(default "60"))
(scheduler-interval virtuoso-configuration-scheduler-interval
(default "10"))
;; Database settings
(database-file virtuoso-configuration-database-file
(default "/var/lib/virtuoso/virtuoso.db"))
(lock-file virtuoso-configuration-lock-file
(default "/var/lib/virtuoso/virtuoso.lck"))
(transaction-file virtuoso-configuration-transaction-file
(default "/var/lib/virtuoso/virtuoso.trx"))
(syslog virtuoso-configuration-syslog
(default "0")))
(define (virtuoso-activation config)
(with-imported-modules '((guix build utils))
#~(begin
(use-modules (guix build utils))
(for-each (lambda (file)
(chown file
(passwd:uid (getpw "virtuoso"))
(passwd:gid (getpw "virtuoso"))))
(find-files #$(virtuoso-configuration-state-directory config)
#:directories? #t)))))
(define %virtuoso-accounts
(list (user-group (name "virtuoso")
(system? #t))
(user-account
(name "virtuoso")
(group "virtuoso")
(system? #t)
(comment "Virtuoso user")
(home-directory "/var/lib/virtuoso")
(shell (file-append shadow "/sbin/nologin")))))
(define (virtuoso-shepherd-service config)
(shepherd-service
(documentation "Run Virtuoso.")
(provision '(virtuoso))
(start #~(make-forkexec-constructor
(list #$(file-append (virtuoso-configuration-package config)
"/bin/virtuoso-t")
"+foreground"
"+configfile"
#$(computed-file
"virtuoso.ini"
#~(call-with-output-file #$output
(lambda (port)
(when (and #$(virtuoso-configuration-server-ip config)
#$(virtuoso-configuration-server-port config))
(format port "[Parameters]~%")
(format port "ServerPort = ~a:~a~%"
#$(virtuoso-configuration-server-ip config)
#$(virtuoso-configuration-server-port config)))
(when #$(virtuoso-dirs-allowed config)
(format port "DirsAllowed = ~a~%"
#$(virtuoso-dirs-allowed config)))
(when #$(virtuoso-configuration-number-of-buffers config)
(format port "NumberOfBuffers = ~a~%"
#$(virtuoso-configuration-number-of-buffers config)))
(when #$(virtuoso-configuration-maximum-dirty-buffers config)
(format port "MaxDirtyBuffers = ~a~%"
#$(virtuoso-configuration-maximum-dirty-buffers config)))
(when (and #$(virtuoso-configuration-http-server-ip config)
#$(virtuoso-configuration-http-server-port config))
(format port "[HTTPServer]~%")
(format port "ServerPort = ~a:~a~%"
#$(virtuoso-configuration-http-server-ip config)
#$(virtuoso-configuration-http-server-port config)))
(format port
"[Database]~%DatabaseFile = ~a~%LockFile = ~a~%TransactionFile = ~a~%Syslog = ~a~%"
#$(virtuoso-configuration-database-file config)
#$(virtuoso-configuration-lock-file config)
#$(virtuoso-configuration-transaction-file config)
#$(virtuoso-configuration-syslog config))))))
#:directory #$(virtuoso-configuration-state-directory config)
#:user "virtuoso"
#:group "virtuoso"
#:log-file "/var/log/virtuoso.log"))
(stop #~(make-kill-destructor))))
(define virtuoso-service-type
(service-type
(name 'virtuoso)
(description "Run Virtuoso.")
(extensions
(list (service-extension activation-service-type
virtuoso-activation)
(service-extension account-service-type
(const %virtuoso-accounts))
(service-extension shepherd-root-service-type
(compose list virtuoso-shepherd-service))))
(default-value (virtuoso-configuration))))
|