jerbil 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Bugs.rdoc +66 -0
- data/Gemfile +12 -0
- data/History.txt +359 -0
- data/Intro.txt +5 -0
- data/LICENCE.rdoc +159 -0
- data/README.md +335 -0
- data/README_SERVICES.md +410 -0
- data/README_TESTING.md +47 -0
- data/bin/jerbil +62 -0
- data/bin/jerbil-install +56 -0
- data/etc/conf.d/jerbild +15 -0
- data/etc/conf.d/jserviced +39 -0
- data/etc/init.d/jerbild +55 -0
- data/etc/init.d/jserviced +59 -0
- data/etc/jerbil/jerbil-client.rb +2 -0
- data/etc/jerbil/jerbil.rb +83 -0
- data/lib/jerbil.rb +636 -0
- data/lib/jerbil/config.md +49 -0
- data/lib/jerbil/config.rb +67 -0
- data/lib/jerbil/errors.rb +74 -0
- data/lib/jerbil/jerbil_service/base.rb +191 -0
- data/lib/jerbil/jerbil_service/client.rb +325 -0
- data/lib/jerbil/jerbil_service/config.md +119 -0
- data/lib/jerbil/jerbil_service/config.rb +72 -0
- data/lib/jerbil/jerbil_service/sclient.rb +343 -0
- data/lib/jerbil/jerbil_service/support.rb +58 -0
- data/lib/jerbil/jerbil_service/utils.rb +35 -0
- data/lib/jerbil/servers.rb +230 -0
- data/lib/jerbil/service.rb +216 -0
- data/lib/jerbil/support.rb +160 -0
- data/lib/jerbil/thor/server.rb +76 -0
- data/lib/jerbil/thor/service.rb +74 -0
- data/lib/jerbil/version.rb +13 -0
- data/sbin/jerbil-status +120 -0
- data/sbin/jerbil-stop +139 -0
- data/sbin/jerbild +186 -0
- data/sbin/jservice-status +107 -0
- data/sbin/jservice-stop +94 -0
- data/sbin/jserviced +111 -0
- data/spec/jerbil_2_jerbil_spec.rb +87 -0
- data/spec/jerbil_client1_spec.rb +80 -0
- data/spec/jerbil_client_spec.rb +114 -0
- data/spec/jerbil_client_stop_spec.rb +24 -0
- data/spec/jerbil_daemonised/jerbil_local_spec.rb +81 -0
- data/spec/jerbil_daemonised/jerbil_remote_spec.rb +116 -0
- data/spec/jerbil_load.rb +48 -0
- data/spec/jerbil_local_spec.rb +91 -0
- data/spec/jerbil_missing_spec.rb +98 -0
- data/spec/jerbil_remote_spec.rb +117 -0
- data/spec/jerbil_remote_spec_bup.rb +168 -0
- data/spec/jerbil_service_error_spec.rb +56 -0
- data/spec/jerbil_service_spec.rb +41 -0
- data/spec/jerbil_support_spec.rb +69 -0
- data/spec/jservice_utils_spec.rb +38 -0
- data/spec/server_spec.rb +69 -0
- data/spec/server_update_spec.rb +28 -0
- data/spec/service_spec.rb +72 -0
- data/spec/spec_helper.rb +12 -0
- data/spec/test_env_spec.rb +53 -0
- data/test/bad_test_service.rb +31 -0
- data/test/conf.d/jerbil +36 -0
- data/test/conf.d/jerbil.conf +39 -0
- data/test/conf.d/jerbil.rb +55 -0
- data/test/conf.d/jerbil_local.rb +33 -0
- data/test/conf.d/jerbil_no_local.conf +39 -0
- data/test/conf.d/jerbil_old.rb +47 -0
- data/test/conf.d/jerbil_test.rb +35 -0
- data/test/conf.d/malformed +1 -0
- data/test/conf.d/missing_services +39 -0
- data/test/conf.d/ruby_test.rb +8 -0
- data/test/init.d/jerbild +14 -0
- data/test/jerbil.rb +51 -0
- data/test/jerbil_config.rb +8 -0
- data/test/jstop.rb +36 -0
- data/test/key.asc +1 -0
- data/test/lib/ruby_test.rb +37 -0
- data/test/lib/ruby_test/config.rb +56 -0
- data/test/lib/ruby_test/version.rb +13 -0
- data/test/pids/jerbil-prod.asc +1 -0
- data/test/pids/jerbil-prod.pid +1 -0
- data/test/pids/jerbil.pid +1 -0
- data/test/private_key_file.asc +3 -0
- data/test/service-stop.rb +86 -0
- data/test/service_mock.rb +94 -0
- data/test/test_service_client.rb +25 -0
- metadata +265 -0
data/sbin/jerbild
ADDED
@@ -0,0 +1,186 @@
|
|
1
|
+
#!/usr/bin/env ruby18
|
2
|
+
# Description
|
3
|
+
#
|
4
|
+
# Author:: Robert Sharp
|
5
|
+
# Copyright:: Copyright (c) 2010 Robert Sharp
|
6
|
+
# License:: Open Software Licence v3.0
|
7
|
+
#
|
8
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
9
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
10
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
11
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
12
|
+
#
|
13
|
+
#
|
14
|
+
|
15
|
+
#
|
16
|
+
# Start the Jerbil Server
|
17
|
+
#
|
18
|
+
|
19
|
+
require 'jerbil'
|
20
|
+
require 'jerbil/servers'
|
21
|
+
require 'jerbil/config'
|
22
|
+
require 'jerbil/version'
|
23
|
+
require 'jerbil/support'
|
24
|
+
|
25
|
+
require 'jellog'
|
26
|
+
require 'jeckyl'
|
27
|
+
|
28
|
+
require 'socket'
|
29
|
+
require 'drb'
|
30
|
+
require 'rubygems'
|
31
|
+
require 'daemons'
|
32
|
+
require 'optparse'
|
33
|
+
|
34
|
+
config_file = nil # let it be the default
|
35
|
+
daemonize = true
|
36
|
+
log_to_syslog = true
|
37
|
+
verbose = false
|
38
|
+
env = nil
|
39
|
+
|
40
|
+
OptionParser.new do |opts|
|
41
|
+
|
42
|
+
opts.banner = "Usage: jerbild [opts]"
|
43
|
+
opts.separator ""
|
44
|
+
opts.separator " start the Jerbil Daemon"
|
45
|
+
opts.separator ""
|
46
|
+
|
47
|
+
opts.on("-n", "--no-daemon", "Do not daemonize") do
|
48
|
+
daemonize = false
|
49
|
+
end
|
50
|
+
|
51
|
+
opts.on("-S", "--no-syslog", "Do not log to syslog") do
|
52
|
+
log_to_syslog = false
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.on("-c", "--config [file]", String, "use this config file to find Jerbil" ) do |cfile|
|
56
|
+
if FileTest.readable?(cfile) then
|
57
|
+
config_file = cfile
|
58
|
+
else
|
59
|
+
puts "Config file cannot be read."
|
60
|
+
exit 1
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
opts.on("-e", "--environment [TYPE]", [:prod, :test, :dev], "Select env (prod, test, dev), default is prod") do |e|
|
65
|
+
env = e
|
66
|
+
end
|
67
|
+
|
68
|
+
opts.on("-V", "--verbose", "output more information about what is going on ") do
|
69
|
+
verbose = true
|
70
|
+
end
|
71
|
+
|
72
|
+
opts.on("-h", "--help", "Provide Help") do |h|
|
73
|
+
opts.separator ""
|
74
|
+
puts opts
|
75
|
+
exit 0
|
76
|
+
end
|
77
|
+
|
78
|
+
end.parse!
|
79
|
+
|
80
|
+
puts "Starting the Jerbil Server (#{Jerbil::Ident})" if verbose
|
81
|
+
|
82
|
+
|
83
|
+
begin
|
84
|
+
config = Jerbil.get_config(config_file)
|
85
|
+
|
86
|
+
#my_self = Jerbil.get_local_server(config_file)
|
87
|
+
rescue Jerbil::JerbilConfigError => err
|
88
|
+
puts "Error in Jerbil Config File: #{err.message}"
|
89
|
+
exit 1
|
90
|
+
rescue Jerbil::MissingServer
|
91
|
+
puts "Failed to find a local server in the config file. Check environment settings"
|
92
|
+
exit 1
|
93
|
+
end
|
94
|
+
|
95
|
+
if env then
|
96
|
+
config[:environment] = env
|
97
|
+
end
|
98
|
+
|
99
|
+
if verbose then
|
100
|
+
puts "Config hash:"
|
101
|
+
config.each_pair do |key, value|
|
102
|
+
puts " #{key}: #{value}"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
|
107
|
+
# create a private key for jerbil
|
108
|
+
pkey = Jerbil::Support.create_private_key(:jerbil, config[:environment], config[:key_dir])
|
109
|
+
puts "Created Private Key" if verbose
|
110
|
+
|
111
|
+
# check the pid directory has been set
|
112
|
+
unless config[:pid_dir] then
|
113
|
+
puts "You must provide a writeable pid_dir in the config file!"
|
114
|
+
exit 1
|
115
|
+
end
|
116
|
+
|
117
|
+
# prevent the server from generating syslogs
|
118
|
+
Jellog::Logger.disable_syslog unless log_to_syslog
|
119
|
+
|
120
|
+
# create a local log
|
121
|
+
|
122
|
+
dopts = {:backtrace=>true,
|
123
|
+
:app_name=>'jerbil_daemon',
|
124
|
+
:log_dir=>config[:log_dir],
|
125
|
+
:log_output=>true,
|
126
|
+
:dir_mode=>:normal,
|
127
|
+
:dir=>config[:pid_dir]
|
128
|
+
}
|
129
|
+
|
130
|
+
logger = nil
|
131
|
+
|
132
|
+
begin
|
133
|
+
if daemonize then
|
134
|
+
puts "Daemonizing now" if verbose
|
135
|
+
Daemons.daemonize(dopts)
|
136
|
+
log_opts = Jellog::Config.intersection(config)
|
137
|
+
#log_opts[:log_level] = :debug
|
138
|
+
logger = Jellog::Logger.new('jerbil_sd', log_opts)
|
139
|
+
#config = config.merge(log_opts) # add them back!
|
140
|
+
else
|
141
|
+
puts "Running in the foreground" if verbose
|
142
|
+
logger = $stderr
|
143
|
+
end
|
144
|
+
|
145
|
+
rescue => err
|
146
|
+
|
147
|
+
File.open('/tmp/jerbil_panic.log', 'w') do |pfile|
|
148
|
+
pfile.puts "Panic during daemonization:"
|
149
|
+
pfile.puts "#{err.class.to_s}: #{err.message}"
|
150
|
+
err.backtrace.each do |bt|
|
151
|
+
pfile.puts(bt)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
exit 1
|
156
|
+
end
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
logger.puts "Logging started for Jerbil Daemon"
|
161
|
+
logger.puts "Daemonized" if verbose && daemonize
|
162
|
+
|
163
|
+
my_self = Jerbil::Servers.create_local_server(config[:environment], pkey)
|
164
|
+
|
165
|
+
logger.puts "Created local server: #{my_self.ident}"
|
166
|
+
|
167
|
+
jerbild = Jerbil::Broker.new(config, pkey)
|
168
|
+
|
169
|
+
logger.puts "Started Broker"
|
170
|
+
|
171
|
+
DRb.start_service(my_self.drb_address, jerbild)
|
172
|
+
|
173
|
+
logger.puts "Started DRb"
|
174
|
+
|
175
|
+
# now create the pid file
|
176
|
+
Jerbil::Support.write_pid_file(:jerbil, config[:environment], config[:pid_dir])
|
177
|
+
|
178
|
+
logger.puts "Written pid #{Process.pid} to pid file"
|
179
|
+
|
180
|
+
$0 = "jerbild-#{config[:environment]}"
|
181
|
+
|
182
|
+
logger.puts "Changed process name for #{my_self.ident}"
|
183
|
+
|
184
|
+
$SAFE = 1 # using DRb, so prevent anything nasty
|
185
|
+
|
186
|
+
DRb.thread.join
|
@@ -0,0 +1,107 @@
|
|
1
|
+
#!/usr/bin/env ruby18
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# = Jerbil Service Stop
|
5
|
+
#
|
6
|
+
# == stops a jerbil service
|
7
|
+
#
|
8
|
+
# Author:: Robert Sharp
|
9
|
+
# Copyright:: Copyright (c) 2012 Robert Sharp
|
10
|
+
# License:: Open Software Licence v3.0
|
11
|
+
#
|
12
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
13
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
14
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
15
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
16
|
+
#
|
17
|
+
# This script should be used to stop a jerbil service, typically through the jerbil init script.
|
18
|
+
#
|
19
|
+
require 'rubygems'
|
20
|
+
|
21
|
+
require 'jerbil/jerbil_service/client'
|
22
|
+
require 'jerbil/jerbil_service/utils'
|
23
|
+
require 'jerbil/errors'
|
24
|
+
|
25
|
+
require 'optparse'
|
26
|
+
|
27
|
+
# force quiet to suppress client output regardless of whether verbose is selected
|
28
|
+
client_opts = {:local=>true, :quiet=>true}
|
29
|
+
|
30
|
+
verbose = false
|
31
|
+
my_service = nil
|
32
|
+
quiet = false
|
33
|
+
OptionParser.new do |opts|
|
34
|
+
|
35
|
+
opts.banner = "Usage: service-status [opts]"
|
36
|
+
opts.separator ""
|
37
|
+
opts.separator " stop the given Jerbil Service"
|
38
|
+
opts.separator ""
|
39
|
+
|
40
|
+
opts.on("-s", "--service [name]", String, "check the given service") do |name|
|
41
|
+
my_service = name
|
42
|
+
end
|
43
|
+
|
44
|
+
opts.on("-n", "--no-daemon", "Do not daemonize") do
|
45
|
+
daemonize = false
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on("-l", "--log-daemon", "ignored") do
|
49
|
+
daemonize = false
|
50
|
+
end
|
51
|
+
|
52
|
+
opts.on("-S", "--no-syslog", "Do not log to syslog") do
|
53
|
+
log_to_syslog = false
|
54
|
+
end
|
55
|
+
|
56
|
+
opts.on("-c", "--config [file]", String, "use this config file instead of the default" ) do |cfile|
|
57
|
+
if FileTest.readable?(cfile) then
|
58
|
+
client_opts[:config_file] = cfile
|
59
|
+
else
|
60
|
+
puts "Config file cannot be read."
|
61
|
+
exit 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
opts.on("-V", "--verbose", "output more information about what is going on ") do
|
66
|
+
verbose = true
|
67
|
+
client_opts[:quiet] = false
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("-q", "--quiet", "output nothing") do
|
71
|
+
quiet = true
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on("-h", "--help", "Provide Help") do |h|
|
75
|
+
opts.separator ""
|
76
|
+
puts opts
|
77
|
+
exit 0
|
78
|
+
end
|
79
|
+
|
80
|
+
end.parse!
|
81
|
+
|
82
|
+
unless my_service
|
83
|
+
puts "Error: You must provide a service (-s name)"
|
84
|
+
exit 1
|
85
|
+
else
|
86
|
+
service_name = JerbilService::Utils.classify(my_service)
|
87
|
+
puts "Checking status for #{service_name}" unless quiet
|
88
|
+
require "#{my_service}"
|
89
|
+
require "#{my_service}/config"
|
90
|
+
require "#{my_service}/version"
|
91
|
+
the_service = Module.const_get(service_name)
|
92
|
+
end
|
93
|
+
|
94
|
+
running = false
|
95
|
+
begin
|
96
|
+
JerbilService::Client.connect(the_service, client_opts) do |jservice|
|
97
|
+
running = jservice.verify
|
98
|
+
end
|
99
|
+
rescue Jerbil::ServiceNotFound
|
100
|
+
running = false
|
101
|
+
end
|
102
|
+
|
103
|
+
if verbose then
|
104
|
+
puts running ? "Service #{service_name} is running" : "Service #{service_name} is not running"
|
105
|
+
end
|
106
|
+
|
107
|
+
running ? exit(0) : exit(1)
|
data/sbin/jservice-stop
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env ruby18
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# = Jerbil Service Stop
|
5
|
+
#
|
6
|
+
# == stops a jerbil service
|
7
|
+
#
|
8
|
+
# Author:: Robert Sharp
|
9
|
+
# Copyright:: Copyright (c) 2012 Robert Sharp
|
10
|
+
# License:: Open Software Licence v3.0
|
11
|
+
#
|
12
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
13
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
14
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
15
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
16
|
+
#
|
17
|
+
#
|
18
|
+
#
|
19
|
+
require 'rubygems'
|
20
|
+
|
21
|
+
require 'jerbil/jerbil_service/sclient'
|
22
|
+
require 'jerbil/jerbil_service/utils'
|
23
|
+
|
24
|
+
require 'optparse'
|
25
|
+
|
26
|
+
config_file = nil # let it be the default
|
27
|
+
verbose = false
|
28
|
+
quiet = false
|
29
|
+
my_service = nil
|
30
|
+
OptionParser.new do |opts|
|
31
|
+
|
32
|
+
opts.banner = "Usage: service-stop [opts]"
|
33
|
+
opts.separator ""
|
34
|
+
opts.separator " stop the given Jerbil Service"
|
35
|
+
opts.separator ""
|
36
|
+
|
37
|
+
opts.on("-s", "--service [name]", String, "start the given service") do |name|
|
38
|
+
my_service = name
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("-n", "--no-daemon", "Do not daemonize") do
|
42
|
+
daemonize = false
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-l", "--log-daemon", "ignored") do
|
46
|
+
daemonize = false
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on("-S", "--no-syslog", "Do not log to syslog") do
|
50
|
+
log_to_syslog = false
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
opts.on("-c", "--config [file]", String, "use this config file to find Jerbil" ) do |cfile|
|
55
|
+
if FileTest.readable?(cfile) then
|
56
|
+
config_file = cfile
|
57
|
+
else
|
58
|
+
puts "Config file cannot be read."
|
59
|
+
exit 1
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
opts.on("-V", "--verbose", "output more information about what is going on ") do
|
64
|
+
verbose = true
|
65
|
+
end
|
66
|
+
|
67
|
+
opts.on("-q", "--quiet", "output nothing") do
|
68
|
+
quiet = true
|
69
|
+
end
|
70
|
+
|
71
|
+
opts.on("-h", "--help", "Provide Help") do |h|
|
72
|
+
opts.separator ""
|
73
|
+
puts opts
|
74
|
+
exit 0
|
75
|
+
end
|
76
|
+
|
77
|
+
end.parse!
|
78
|
+
|
79
|
+
unless my_service
|
80
|
+
puts "Error: You must provide a service (-s name)"
|
81
|
+
exit 1
|
82
|
+
else
|
83
|
+
service_name = JerbilService::Utils.classify(my_service)
|
84
|
+
require "#{my_service}"
|
85
|
+
require "#{my_service}/config"
|
86
|
+
require "#{my_service}/version"
|
87
|
+
the_service = Module.const_get(service_name)
|
88
|
+
end
|
89
|
+
|
90
|
+
JerbilService::Supervisor.stop(the_service) do |jservice|
|
91
|
+
jservice.verbose if verbose
|
92
|
+
jservice.quiet if quiet
|
93
|
+
jservice.config_file = config_file
|
94
|
+
end
|
data/sbin/jserviced
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
#!/usr/bin/env ruby18
|
2
|
+
#
|
3
|
+
#
|
4
|
+
# = Jerbil Service Start
|
5
|
+
#
|
6
|
+
# == starts a jerbil service
|
7
|
+
#
|
8
|
+
# Author:: Robert Sharp
|
9
|
+
# Copyright:: Copyright (c) 2012 Robert Sharp
|
10
|
+
# License:: Open Software Licence v3.0
|
11
|
+
#
|
12
|
+
# This software is licensed for use under the Open Software Licence v. 3.0
|
13
|
+
# The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
|
14
|
+
# and in the file copyright.txt. Under the terms of this licence, all derivative works
|
15
|
+
# must themselves be licensed under the Open Software Licence v. 3.0
|
16
|
+
#
|
17
|
+
#
|
18
|
+
#
|
19
|
+
require 'rubygems'
|
20
|
+
|
21
|
+
require 'jerbil/jerbil_service/sclient'
|
22
|
+
require 'jerbil/jerbil_service/utils'
|
23
|
+
|
24
|
+
require 'optparse'
|
25
|
+
|
26
|
+
config_file = nil # let it be the default
|
27
|
+
daemonize = true
|
28
|
+
log_to_syslog = true
|
29
|
+
verbose = true
|
30
|
+
quiet = false
|
31
|
+
my_service = nil
|
32
|
+
log_daemon = false
|
33
|
+
|
34
|
+
OptionParser.new do |opts|
|
35
|
+
|
36
|
+
opts.banner = "Usage: jservice [opts] -s <name>"
|
37
|
+
opts.separator ""
|
38
|
+
opts.separator " start the jerbil service with the given <name>"
|
39
|
+
opts.separator ""
|
40
|
+
|
41
|
+
opts.on("-s", "--service [name]", String, "start the given service") do |name|
|
42
|
+
my_service = name
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on("-n", "--no-daemon", "Do not daemonize") do
|
46
|
+
daemonize = false
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on("-l", "--log-daemon", "Log daemon output") do
|
50
|
+
log_daemon = true
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on("-S", "--no-syslog", "Do not log to syslog") do
|
54
|
+
log_to_syslog = false
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.on("-c", "--config [file]", String, "use this config file for the service" ) do |cfile|
|
58
|
+
if FileTest.readable?(cfile) then
|
59
|
+
config_file = cfile
|
60
|
+
else
|
61
|
+
puts "Config file cannot be read."
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
opts.on("-V", "--verbose", "output more information about what is going on ") do
|
67
|
+
verbose = true
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on("-q", "--quiet", "output nothing") do
|
71
|
+
quiet = true
|
72
|
+
end
|
73
|
+
|
74
|
+
opts.on("-h", "--help", "Provide Help") do |h|
|
75
|
+
opts.separator ""
|
76
|
+
puts opts
|
77
|
+
exit 0
|
78
|
+
end
|
79
|
+
|
80
|
+
end.parse!
|
81
|
+
|
82
|
+
verbose = false if quiet
|
83
|
+
|
84
|
+
puts "Ready to start. Looking for class" if verbose
|
85
|
+
|
86
|
+
unless my_service
|
87
|
+
puts "Error: You must name a service (-s name)"
|
88
|
+
exit 1
|
89
|
+
else
|
90
|
+
service_name = JerbilService::Utils.classify(my_service)
|
91
|
+
puts "Requiring modules for: #{service_name}" if verbose
|
92
|
+
require "#{my_service}"
|
93
|
+
require "#{my_service}/config"
|
94
|
+
require "#{my_service}/version"
|
95
|
+
puts "Required modules" if verbose
|
96
|
+
the_service = Module.const_get(service_name)
|
97
|
+
puts "Obtained module name: #{the_service}" if verbose
|
98
|
+
end
|
99
|
+
|
100
|
+
puts "Starting the Supervisor" if verbose
|
101
|
+
|
102
|
+
JerbilService::Supervisor.new(the_service) do |jservice|
|
103
|
+
jservice.no_daemon unless daemonize
|
104
|
+
jservice.quiet if quiet
|
105
|
+
jservice.verbose if verbose
|
106
|
+
jservice.log_daemon if log_daemon
|
107
|
+
jservice.no_syslog unless log_to_syslog
|
108
|
+
jservice.config_file = config_file
|
109
|
+
end
|
110
|
+
|
111
|
+
puts "Everything should be working now" if verbose
|