summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--files/subunit-gearman-worker.py10
-rw-r--r--manifests/worker.pp44
-rwxr-xr-xtemplates/jenkins-subunit-worker.init.erb4
3 files changed, 37 insertions, 21 deletions
diff --git a/files/subunit-gearman-worker.py b/files/subunit-gearman-worker.py
index 56ec4b3..36a11b2 100644
--- a/files/subunit-gearman-worker.py
+++ b/files/subunit-gearman-worker.py
@@ -15,10 +15,10 @@
15# under the License. 15# under the License.
16 16
17import argparse 17import argparse
18import cStringIO
19import daemon 18import daemon
20import gear 19import gear
21import gzip 20import gzip
21import io
22import json 22import json
23import logging 23import logging
24import os 24import os
@@ -121,14 +121,14 @@ class SubunitRetriever(threading.Thread):
121 return None 121 return None
122 if gzipped: 122 if gzipped:
123 logging.debug("Decompressing gzipped source file.") 123 logging.debug("Decompressing gzipped source file.")
124 raw_strIO = cStringIO.StringIO(raw_buf) 124 raw_strIO = io.BytesIO(raw_buf)
125 f = gzip.GzipFile(fileobj=raw_strIO) 125 f = gzip.GzipFile(fileobj=raw_strIO)
126 buf = cStringIO.StringIO(f.read()) 126 buf = io.BytesIO(f.read())
127 raw_strIO.close() 127 raw_strIO.close()
128 f.close() 128 f.close()
129 else: 129 else:
130 logging.debug("Decoding source file.") 130 logging.debug("Decoding source file.")
131 buf = cStringIO.StringIO(raw_buf) 131 buf = io.BytesIO(raw_buf)
132 return buf 132 return buf
133 133
134 def _get_subunit_data(self, source_url, retry): 134 def _get_subunit_data(self, source_url, retry):
@@ -243,8 +243,6 @@ class Server(object):
243 self.subunitqueue) 243 self.subunitqueue)
244 244
245 def setup_processor(self): 245 def setup_processor(self):
246 # Note this processor will not work if the process is run as a
247 # daemon. You must use the --foreground option.
248 subunit2sql_config = self.config['config'] 246 subunit2sql_config = self.config['config']
249 self.processor = Subunit2SQLProcessor(self.subunitqueue, 247 self.processor = Subunit2SQLProcessor(self.subunitqueue,
250 subunit2sql_config) 248 subunit2sql_config)
diff --git a/manifests/worker.pp b/manifests/worker.pp
index c4a4344..16b4277 100644
--- a/manifests/worker.pp
+++ b/manifests/worker.pp
@@ -26,33 +26,51 @@ define subunit2sql::worker (
26) { 26) {
27 $suffix = "-${name}" 27 $suffix = "-${name}"
28 28
29 if ! defined(File['/etc/logstash']) { 29 file { '/etc/logstash/':
30 file { '/etc/logstash': 30 ensure => absent,
31 }
32
33 user { 'subunit':
34 ensure => present,
35 system => true,
36 }
37
38 if ! defined(File['/etc/subunit2sql']) {
39 file { '/etc/subunit2sql':
31 ensure => directory, 40 ensure => directory,
32 owner => 'logstash', 41 owner => 'root',
33 group => 'logstash', 42 group => 'root',
34 mode => '0644', 43 mode => '0644',
35 } 44 }
36 } 45 }
37 46
38 if ! defined(File['/etc/logstash/subunit2sql.conf']) { 47if ! defined(File['/var/log/subunit2sql']) {
39 file { '/etc/logstash/subunit2sql.conf': 48 file { '/var/log/subunit2sql':
49 ensure => directory,
50 owner => 'subunit',
51 group => 'subunit',
52 mode => '0644',
53 require => User['subunit'],
54 }
55 }
56 if ! defined(File['/etc/subunit2sql/subunit2sql.conf']) {
57 file { '/etc/subunit2sql/subunit2sql.conf':
40 ensure => present, 58 ensure => present,
41 owner => 'root', 59 owner => 'root',
42 group => 'root', 60 group => 'root',
43 mode => '0555', 61 mode => '0555',
44 content => template('subunit2sql/subunit2sql.conf.erb'), 62 content => template('subunit2sql/subunit2sql.conf.erb'),
45 require => File['/etc/logstash'], 63 require => File['/etc/subunit2sql'],
46 } 64 }
47 } 65 }
48 66
49 file { "/etc/logstash/jenkins-subunit-worker${suffix}.yaml": 67 file { "/etc/subunit2sql/jenkins-subunit-worker${suffix}.yaml":
50 ensure => present, 68 ensure => present,
51 owner => 'root', 69 owner => 'root',
52 group => 'root', 70 group => 'root',
53 mode => '0555', 71 mode => '0555',
54 source => $config_file, 72 source => $config_file,
55 require => File['/etc/logstash'], 73 require => File['/etc/subunit2sql'],
56 } 74 }
57 75
58 file { "/etc/init.d/jenkins-subunit-worker${suffix}": 76 file { "/etc/init.d/jenkins-subunit-worker${suffix}":
@@ -63,7 +81,7 @@ define subunit2sql::worker (
63 content => template('subunit2sql/jenkins-subunit-worker.init.erb'), 81 content => template('subunit2sql/jenkins-subunit-worker.init.erb'),
64 require => [ 82 require => [
65 File['/usr/local/bin/subunit-gearman-worker.py'], 83 File['/usr/local/bin/subunit-gearman-worker.py'],
66 File["/etc/logstash/jenkins-subunit-worker${suffix}.yaml"], 84 File["/etc/subunit2sql/jenkins-subunit-worker${suffix}.yaml"],
67 ], 85 ],
68 } 86 }
69 87
@@ -71,18 +89,18 @@ define subunit2sql::worker (
71 enable => true, 89 enable => true,
72 hasrestart => true, 90 hasrestart => true,
73 subscribe => [ 91 subscribe => [
74 File["/etc/logstash/jenkins-subunit-worker${suffix}.yaml"], 92 File["/etc/subunit2sql/jenkins-subunit-worker${suffix}.yaml"],
75 Package['subunit2sql'], 93 Package['subunit2sql'],
76 ], 94 ],
77 require => [ 95 require => [
78 File['/etc/logstash'], 96 File['/etc/subunit2sql'],
79 File["/etc/init.d/jenkins-subunit-worker${suffix}"], 97 File["/etc/init.d/jenkins-subunit-worker${suffix}"],
80 ], 98 ],
81 } 99 }
82 100
83 include ::logrotate 101 include ::logrotate
84 logrotate::file { "subunit-worker${suffix}-debug.log": 102 logrotate::file { "subunit-worker${suffix}-debug.log":
85 log => "/var/log/logstash/subunit-worker${suffix}-debug.log", 103 log => "/var/log/subunit2sql/subunit-worker${suffix}-debug.log",
86 options => [ 104 options => [
87 'compress', 105 'compress',
88 'copytruncate', 106 'copytruncate',
diff --git a/templates/jenkins-subunit-worker.init.erb b/templates/jenkins-subunit-worker.init.erb
index 5425202..08e6551 100755
--- a/templates/jenkins-subunit-worker.init.erb
+++ b/templates/jenkins-subunit-worker.init.erb
@@ -17,9 +17,9 @@ DESC="Jenkins Subunit Worker"
17NAME=jenkins-subunit-worker<%= suffix %> 17NAME=jenkins-subunit-worker<%= suffix %>
18DAEMON=/usr/local/bin/subunit-gearman-worker.py 18DAEMON=/usr/local/bin/subunit-gearman-worker.py
19PIDFILE=/var/run/$NAME/$NAME.pid 19PIDFILE=/var/run/$NAME/$NAME.pid
20DAEMON_ARGS="-c /etc/logstash/jenkins-subunit-worker<%= suffix %>.yaml -d /var/log/logstash/subunit-worker<%= suffix %>-debug.log -p $PIDFILE" 20DAEMON_ARGS="-c /etc/subunit2sql/jenkins-subunit-worker<%= suffix %>.yaml -d /var/log/subunit2sql/subunit-worker<%= suffix %>-debug.log -p $PIDFILE"
21SCRIPTNAME=/etc/init.d/$NAME 21SCRIPTNAME=/etc/init.d/$NAME
22USER=logstash 22USER=subunit
23 23
24# Exit if the package is not installed 24# Exit if the package is not installed
25[ -x "$DAEMON" ] || exit 0 25[ -x "$DAEMON" ] || exit 0