commit | author | age
|
e66a84
|
1 |
<?xml version='1.0'?> |
JK |
2 |
<!-- |
|
3 |
// |
|
4 |
// |
|
5 |
// This file and its contents are supplied under the terms of the |
|
6 |
// Common Development and Distribution License ("CDDL"), version 1.0. |
|
7 |
// You may only use this file in accordance with the terms of version |
|
8 |
// 1.0 of the CDDL. |
|
9 |
// |
|
10 |
// A full copy of the text of the CDDL should have accompanied this |
|
11 |
// source. A copy of the CDDL is also available via the Internet at |
|
12 |
// http://www.illumos.org/license/CDDL. |
|
13 |
// |
|
14 |
// |
05eb21
|
15 |
// Copyright 2016-2018 by Jim Klimov |
e66a84
|
16 |
// |
JK |
17 |
--> |
|
18 |
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'> |
|
19 |
<service_bundle type='manifest' name='jenkins-standalone'> |
|
20 |
<service |
|
21 |
name='network/http' |
|
22 |
type='service' |
|
23 |
version='1'> |
|
24 |
|
|
25 |
<!-- |
|
26 |
Because we may have multiple instances of network/http |
|
27 |
provided by different implementations, we keep dependencies |
|
28 |
and methods within the instance. |
|
29 |
--> |
|
30 |
|
|
31 |
<instance name='jenkins' enabled='false'> |
|
32 |
<!-- |
|
33 |
Note that while there may be automated deployments of Jenkins |
|
34 |
managed as a web-application in a container like Tomcat, it |
|
35 |
would likely not be a separate SMF service, so names are not |
|
36 |
likely to collide - while this shorthand default is convenient. |
|
37 |
--> |
|
38 |
|
|
39 |
<!-- |
|
40 |
Wait for network interfaces to be initialized. |
|
41 |
--> |
|
42 |
<dependency name='network' |
|
43 |
grouping='require_all' |
|
44 |
restart_on='error' |
|
45 |
type='service'> |
|
46 |
<service_fmri value='svc:/milestone/network:default'/> |
|
47 |
</dependency> |
|
48 |
|
|
49 |
<!-- |
|
50 |
Wait for all local filesystems to be mounted. |
|
51 |
--> |
|
52 |
<dependency name='filesystem-local' |
|
53 |
grouping='require_all' |
|
54 |
restart_on='none' |
|
55 |
type='service'> |
|
56 |
<service_fmri |
|
57 |
value='svc:/system/filesystem/local:default'/> |
|
58 |
</dependency> |
|
59 |
|
|
60 |
<!-- |
|
61 |
Wait for automounting to be available, as we may be |
|
62 |
serving data from home directories or other remote |
|
63 |
filesystems. |
|
64 |
--> |
|
65 |
<dependency name='autofs' |
|
66 |
grouping='optional_all' |
|
67 |
restart_on='error' |
|
68 |
type='service'> |
|
69 |
<service_fmri |
|
70 |
value='svc:/system/filesystem/autofs:default'/> |
|
71 |
</dependency> |
|
72 |
|
|
73 |
<!-- TODO: Wrap this in a script? There are many possible CLI options to consider, |
|
74 |
both for JAVA and the JAR itself... Or keep it simple? --> |
|
75 |
<exec_method type='method' |
|
76 |
name='start' |
e37526
|
77 |
exec='/usr/bin/java -DsessionTimeout=%{httpd/sessionTimeout} -DsessionEviction=%{httpd/sessionEviction} -jar %{httpd/jenkins_war_file} --httpPort=%{httpd/httpPort} --httpListenAddress=%{httpd/httpHost} --webroot=%{httpd/jenkins_war_dir} &' |
e66a84
|
78 |
timeout_seconds='240'> |
JK |
79 |
<method_context> |
|
80 |
<method_credential user='jenkins' group='jenkins' privileges='basic,net_privaddr'/> |
|
81 |
<!-- TODO: Configure these by properties? See also a wrap-script TODO above --> |
|
82 |
<method_environment> |
|
83 |
<envvar name='JENKINS_HOME' value='/var/lib/jenkins/home'/> |
|
84 |
<envvar name='LIBZFS4J_ABI' value='openzfs'/> |
|
85 |
</method_environment> |
|
86 |
</method_context> |
|
87 |
</exec_method> |
|
88 |
|
cac0ac
|
89 |
<!-- Note: Jenkins has a CLI and scriptable REST API that can e.g. schedule |
JK |
90 |
a graceful exit, after all running jobs are finished (and blocking |
|
91 |
creation of new executions), or to do an immediate exit. If a wrapper |
|
92 |
script is made for the SMF methods, use of this should be an option. |
|
93 |
Otherwise, handling of SIGTERM is also graceful, though abrupt :) |
|
94 |
--> |
e66a84
|
95 |
<exec_method type='method' |
JK |
96 |
name='stop' |
cac0ac
|
97 |
exec=':kill -TERM' |
JK |
98 |
timeout_seconds='60'> |
|
99 |
<method_context> |
|
100 |
<method_credential user='jenkins' group='jenkins' /> |
|
101 |
</method_context> |
|
102 |
</exec_method> |
|
103 |
|
|
104 |
<!-- At the bare minimum, we want to restart and redeploy the WAR file and |
|
105 |
its Jetty container when the service is refreshed (e.g. package update). |
|
106 |
So we just kill it (if running) and hope SMF restart would do the rest. |
|
107 |
--> |
|
108 |
<exec_method type='method' |
|
109 |
name='refresh' |
e66a84
|
110 |
exec=':kill -TERM' |
JK |
111 |
timeout_seconds='60'> |
|
112 |
<method_context> |
|
113 |
<method_credential user='jenkins' group='jenkins' /> |
|
114 |
</method_context> |
|
115 |
</exec_method> |
|
116 |
|
|
117 |
<!-- Note: the jenkins.war startup options are documented at: |
|
118 |
https://wiki.jenkins-ci.org/pages/viewpage.action?pageId=73533946 |
|
119 |
Parameters not recognized by the WAR are passed to Winstone container: |
|
120 |
http://winstone.sourceforge.net/#commandLine |
cac0ac
|
121 |
If you plan to shield the Jenkins application server by a reverse proxy |
JK |
122 |
like nginx, apache mod_proxy, etc. running in the same zone - consider |
|
123 |
setting httpHost=127.0.0.1 below. Conversely, to run Jenkins as "the" |
|
124 |
webserver in this operating environment, note that this SMF service is |
|
125 |
sufficiently privileged to use httpPort numbers under 1024 (e.g. 80). |
e66a84
|
126 |
--> |
JK |
127 |
<property_group name='httpd' type='application'> |
|
128 |
<stability value='Evolving' /> |
|
129 |
<propval name='httpPort' type='count' value='8080' /> |
4f127d
|
130 |
<propval name='httpHost' type='astring' value='0.0.0.0' /> |
e66a84
|
131 |
<propval name='jenkins_war_file' type='astring' value='/usr/share/jenkins/war/jenkins.war' /> |
cac0ac
|
132 |
<!-- Directory into which Jetty webserver would unpack the WAR file --> |
JK |
133 |
<propval name='jenkins_war_dir' type='astring' value='/var/lib/jenkins/standalone-war' /> |
05eb21
|
134 |
<!-- There are two options in winstone server, one for overall |
JK |
135 |
session duration (remember me), another for session-eviction |
|
136 |
after a window/tab with Jenkins was closed in browser --> |
|
137 |
<propval name='sessionTimeout' type='count' value='1440' /> |
|
138 |
<propval name='sessionEviction' type='count' value='1440' /> |
e66a84
|
139 |
</property_group> |
JK |
140 |
|
|
141 |
<property_group name='startd' type='framework'> |
|
142 |
<!-- sub-process core dumps shouldn't restart |
|
143 |
session --> |
|
144 |
<propval name='ignore_error' type='astring' |
|
145 |
value='core,signal' /> |
e37526
|
146 |
<propval name='duration' type='astring' value='contract' /> |
e66a84
|
147 |
</property_group> |
JK |
148 |
|
|
149 |
<template> |
|
150 |
<common_name> |
|
151 |
<loctext xml:lang='C'>Jenkins CI - standalone service</loctext> |
|
152 |
</common_name> |
|
153 |
</template> |
|
154 |
|
|
155 |
</instance> |
|
156 |
|
|
157 |
<stability value='Evolving' /> |
|
158 |
|
|
159 |
</service> |
|
160 |
</service_bundle> |