jerbil 1.3.3 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YjBlMmZlMjU5N2FhNDY2NzIwOTJlYTNlMWUzMzUwZmI0MjIzMjZiOA==
4
+ OThlODQwNmFhOWZlOWUwMjYxYWU0MjY5ZGRhYTBjNGI1YzBiYjU2NQ==
5
5
  data.tar.gz: !binary |-
6
- MzBjYmIzY2Q1M2EzMjhjYTZlN2FmMDcxNzMzYjJhOGMyYWMwY2I0MA==
7
- !binary "U0hBNTEy":
6
+ ZGU5MTgzZTgzYzNlY2Y4NjQ1OTcwMjJmZTY1MzllOTVhYzAyYjc0MA==
7
+ SHA512:
8
8
  metadata.gz: !binary |-
9
- OGIzZjRhY2IxZDdkMGYyNTI1MDE0ZjRjMjc5ZGQ2OTU2ZGU5ZjEyNWQwNDY3
10
- ZjdjYmVmMDU5ZDIzOTdkYTc5MjczMGM0MmY3MmVjZWI3YmRjNDI1ZTY4NGE0
11
- YzQ1ZDAyNGFjODNiZWNhMzM4MTAzNTNkMGExY2U2OTZiMjYxYjQ=
9
+ M2QxMWI2ZjUyMzk4ZDZiMTNkMTk5N2Y4Mzk3YjhhNGY2YjQ1NWY2MWQ0NGMw
10
+ YWM0NzgxZDg4NjVjYmE1ZjMzNzFlMzQ3ZjIyODdiYjhmNWJiMTU4Y2U3YzRi
11
+ ZWYyOTlhODMxNTJjOGQ1MGExYTUxN2RmOTczNGZhMTgyY2NiMTU=
12
12
  data.tar.gz: !binary |-
13
- NDkyYmIxZWNlZDVhM2Y2NzgxOGNkYjQ5M2JkN2Y2ZDE5M2YxMDUyZDk1OTdm
14
- YjhiMDM2MzMzZjQ4MmYyNGM2OWI5NmY3NThjMTc3NDMwZTdiNGE4ZWM2Mzg2
15
- OGMyY2VkZWQyODJiMTI5OTFmODc5M2EyYWZkYmE2Y2ZmODYxOTk=
13
+ NTJjNzU5ZmYzMzA5ZGNlNzI3ZGViYTQxMjUyYmI0MGE0OTcyYTFhNjU4YjYw
14
+ ZDE2NmFlNjNiZDg5MmZlNTdhNWJjMzU1MmM1N2Q5NmY1MGU0ZDBlYzFkZjA2
15
+ ZDJmMTNjZmFkYjg1MjE5NDQwYjMwNzlkYjE4ZjQ0YTYxOTM0YWM=
data/Bugs.rdoc CHANGED
@@ -1,11 +1,18 @@
1
1
  == Bugs
2
2
 
3
+ [jerbil-1.4.4 16-Oct-2014]
4
+
5
+ Started up a service with a previous version still running and it did not detect or
6
+ notify the problem!
7
+
3
8
  [jerbil-1.3.1 29-Aug-2013]
4
9
 
5
10
  Need to update jerbil command to get rid of thor and improve what it does.
6
11
  Consider Network Dependencies - where a service on one machine does not start
7
12
  without a service on another or when a service is taken down on which others depend
8
13
  then they are notified first, through Jerbil?
14
+
15
+ [Thor removed in 2014]
9
16
 
10
17
  [jerbil-1.2.3 06-June-2013]
11
18
 
data/Gemfile CHANGED
@@ -1,14 +1,13 @@
1
1
  # @markup ruby
2
2
  #
3
3
  # general utilities
4
- gem 'netaddr'
5
- gem 'term-ansicolor'
6
- gem 'thor'
7
- gem 'daemons'
4
+ gem 'netaddr', '~> 1.0'
5
+ gem 'term-ansicolor', '~> 1.0'
6
+ gem 'daemons', '~> 1.0'
8
7
 
9
8
  # jerbil-related utilities
10
- gem 'jellog', '>=1.0.14' # for logging
11
- gem 'jeckyl', '>=0.2.7' # for config files
12
- gem 'jeni', '>=0.2.5' # for installation
9
+ gem 'jellog', '~> 1.0', '>=1.0.14' # for logging
10
+ gem 'jeckyl', '~> 0.2', '>=0.2.7' # for config files
11
+ gem 'jeni', '~> 0.2', '>=0.2.5' # for installation
13
12
 
14
- gem 'optplus', '>=0.0.2'
13
+ gem 'optplus', '~> 0.0', '>=0.0.2'
@@ -4,6 +4,34 @@
4
4
 
5
5
  ==History
6
6
 
7
+ [jerbil-1.4.5 17-Oct-2014]
8
+
9
+ Add server version to 'jerbil remotes -V' and add system logging for start and
10
+ end of monitor process.
11
+
12
+ [jerbil-1.4.4 13-Oct-2014]
13
+
14
+ Fix Gemfile dependencies to please rubygems and remove thor as a dependency.
15
+
16
+ [jerbil-1.4.3 13-Oct-2014]
17
+
18
+ Ensure monitor raises the alarm if the secret key is rejected by another server.
19
+
20
+ [jerbil-1.4.2 09-Oct-2014]
21
+
22
+ Fix jeni installer error.
23
+
24
+ [jerbil-1.4.1 03-Aug-2014]
25
+
26
+ Relocate server discovery to Jerbil::Monitor. Tidy up tests and readmes. Allow for
27
+ gethostname not to return fqdn and use gethostbyname if this happens.
28
+
29
+ [jerbil-1.4.0 19-Apr-2014]
30
+
31
+ Ensure that jerbild init does not complete until the server has completed
32
+ discovery. This prevents services from starting when there is apparently
33
+ a server but it is not yet ready for them.
34
+
7
35
  [jerbil-1.3.3 03-Sep-2013]
8
36
 
9
37
  Ensure jerbil methods are called on the server and not the server record.
data/Intro.txt CHANGED
@@ -1,5 +1,9 @@
1
- Provides an Object Request Broker and service framework for ruby-based services.
1
+ Provides a reliable Object Request Broker and a simple framework for ruby-based services.
2
2
  Jerbil servers run on each machine in the system and share information on registering
3
- services. A parent class for services hides all of the jerbil interactions and client
4
- and supervisor modules hide interactions from scripts or applications interacting
5
- with these services.
3
+ services. This ensures no single point of failure - machines can come and go (orderly or disorderly)
4
+ and the network extends or heals as they do. For services there is a parent class that hides
5
+ all of the jerbil server interactions so that new services can be written without having
6
+ to write any distributing code. Clients can also be written using an interface that
7
+ can find one or more services on the network and connect to each or the first. Finally, there
8
+ are scripts to start and stop the Jerbil server and any Services so that the whole thing
9
+ can be quickly installed and integrated with your system.
data/README.md CHANGED
@@ -1,10 +1,18 @@
1
1
  # Jerbil
2
2
 
3
- **(a.k.a Jumpin Ermin's Reliable Broker for Integrated Linux services)**
3
+ A "Framework" for writing services in Ruby that provides a reliable way to deploy
4
+ services across a network. Reliability is a key objective and with a server
5
+ on each machine you can rely on Jerbil to connect you effortlessly to your services
6
+ wherever they are running.
4
7
 
5
- An Object Broker for ruby that provides reliable access to services across the LAN
6
- and comes complete with a service class that makes writing services easy, hiding all
7
- of the broker interactions.
8
+ Jerbil comes complete with a basic service class to make writing a new service very
9
+ quick and easy. It also has helpers to connect clients to services through Jerbil
10
+ without having to worry about where the service is running. You can find single or
11
+ multiple services and you can run services at development, test or production status
12
+ all on the same LAN or same machine.
13
+
14
+ Overall, Jerbil should save anyone looking to develop a service in Ruby from a lot of
15
+ tedious work and should avoid a lot of the headaches of alternatives such as Rinda.
8
16
 
9
17
  **GitHub:** [https://github.com/osburn-sharp/jerbil](https://github.com/osburn-sharp/jerbil)
10
18
 
@@ -22,7 +30,8 @@ uses the Jerbil Server
22
30
 
23
31
  ### Note
24
32
 
25
- Jerbil will work on any Linux distro (and possibly other systems too) but it comes with
33
+ Jerbil **(a.k.a Jumpin Ermin's Reliable Broker for Integrated Linux services)** will
34
+ work on any Linux distro (and possibly other systems too) but it comes with
26
35
  all the gear necessary to work on Gentoo out of the box - e.g. runscripts, /etc/conf.d files
27
36
  and the like.
28
37
 
@@ -71,13 +80,19 @@ the defaults, you need to generate a secret. A random secret can be generated us
71
80
 
72
81
  # jerbil server secret
73
82
 
74
- although any long string will do. Full details of the configuration parameters for Jerbil are in {Jerbil::Config}.
83
+ although any long string will do.
84
+
85
+ You also need to set some parameters for your network. This is to help the server
86
+ discover any other Jerbil servers on the network without having to hard-code
87
+ this information on all computers. Further details on Server Discovery are provided below.
88
+ Full details of the configuration parameters for Jerbil are in {Jerbil::Config}.
75
89
 
76
90
  ### Editting /etc/services
77
91
 
78
- Jerbil uses /etc/services to find its services (unsurprisingly) so this file needs to be updated. There must
79
- be an entry for the server itself, as well as the services that use jerbil. Because Jerbil supports three
80
- operating environments (dev, test and prod), these services must be assigned in triplets. The following is an example
92
+ Jerbil uses /etc/services (Socket.getservbyname) to find the ports for its services (unsurprisingly) so this
93
+ file needs to be updated. There must be an entry for the Jerbil server itself, as well as the
94
+ services that use Jerbil. Because Jerbil supports three operating environments (dev, test and prod),
95
+ these services must be assigned in triplets. The following is an example
81
96
 
82
97
  # starts from 49195
83
98
  #
@@ -109,31 +124,33 @@ and offsets it if either test or dev is selected. They are included here as a re
109
124
  Once you have generated a secret and set up some services in /etc/services, it is now possible to
110
125
  start the Jerbil Server. This can be done using the jerbild script:
111
126
 
112
- # /usr/sbin/jerbild
127
+ # /usr/local/sbin/jerbild
113
128
 
114
- which will start the server, get the default config file (/etc/jermine/jerbil.rb), daemonise, and say very little.
129
+ which will start the server, get the default config file (/etc/jerbil/jerbil.rb), daemonise, and say very little.
115
130
  If you add the -h or --help switch you can see how to overide this default behaviour.
116
131
  You can then test that the server is running with:
117
132
 
118
- # jerbil server
133
+ # jerbil status
119
134
 
120
135
  If this does not report the server as up, go to the troubleshooting section.
121
136
 
122
- If you can support init scripts, then jerbil is ready to go. Edit /etc/conf.d/jerbild if you need to change settings such as
123
- where the config file is and then run:
137
+ If you can support init scripts, then jerbil is ready to go. Edit /etc/conf.d/jerbild if
138
+ you need to change settings such as where the config file is and then run:
124
139
 
125
140
  # /etc/init.d/jerbild start
141
+ or alternatively
142
+ # rc-service jerbild start
143
+ and to set the service to run at startup:
126
144
  # rc-update add jerbild default
127
145
 
128
- the latter command works on Gentoo at least.
129
146
 
130
147
  You can also check if the server is working using:
131
148
 
132
- # /etc/init.d/jerbild status
149
+ # rc-service jerbild status
133
150
 
134
151
  To stop the server:
135
152
 
136
- # /etc/init.d/jerbild stop
153
+ # rc-service jerbild stop
137
154
 
138
155
  If your distro does not support runscripts like this, then you can start, stop and test status
139
156
  manually using:
@@ -147,7 +164,7 @@ Further details of all these commands can be obtained with the -h or --help opti
147
164
 
148
165
  ## General Description
149
166
 
150
- The function of Jerbil is to make it easy to write linux services in ruby that can be deployed anywhere on
167
+ The aim of Jerbil is to make it easier to write Linux services in Ruby that can be deployed anywhere on
151
168
  a network, once or multiple times, and enabling clients to access these services regardless of where they are. Its
152
169
  a wrapper around DRb and a replacement for Rinda.
153
170
 
@@ -160,7 +177,7 @@ single point of failure. If it goes down nobody can find anything and all servic
160
177
  server is restored.
161
178
 
162
179
  Part of the self-healing in Jerbil is dealing with services that become unavailable. When this happens, the server
163
- checks if the services local server is running. If it is, this local server is asked to deal with the missing service
180
+ checks if the service's local server is running. If it is, this local server is asked to deal with the missing service
164
181
  and update the database accordingly. If it is not, then the original server takes responsibility for the missing
165
182
  service and purges it from all the other servers.
166
183
 
@@ -175,8 +192,8 @@ Jerbil with only a couple of lines of code.
175
192
 
176
193
  Controlling a service is also made easy by the {JerbilService::Supervisor} class. This hides all of the actions needed
177
194
  to start a service. However, service control is made even easier by /usr/bin/jserviced, which starts any service
178
- given that services name, provided the files conform to certain protocols. The /usr/sbin/jservice-status and
179
- /usr/sbin/jservice-stop commands work in a similar manner.
195
+ given that services name, provided the files conform to certain protocols. The /usr/local/sbin/jservice-status and
196
+ /usr/local/sbin/jservice-stop commands work in a similar manner.
180
197
 
181
198
  Writing a client is similarly made easy by the {JerbilService::Client} class, which finds one or more services ready
182
199
  to be connected to and acted upon.
@@ -194,7 +211,7 @@ Jerbil is divided into two groups: the server and the services that use the serv
194
211
 
195
212
  The server consists of one main class: {Jerbil::Broker} and two data-type classes:
196
213
  {Jerbil::Servers} and {Jerbil::ServiceRecord}. The Broker contains the main server code,
197
- finding and registering with other servers, accepting and recording services and
214
+ accepting and recording services and
198
215
  responding to queries about registered services. When a service registers with
199
216
  the broker, the broker will also inform all of the other servers of that service.
200
217
  The {Jerbil::Servers} class is used by the broker to record information
@@ -202,15 +219,6 @@ about a server and it provides convenience methods to connect to a server and a
202
219
  method to find the local server. The {Jerbil::ServiceRecord} class fulfils a similar
203
220
  role for services.
204
221
 
205
- When a server starts up it uses the {Jerbil::Servers.find_servers} class method to
206
- search the network for any other servers. This method uses the NetAddr gem to create a
207
- list of network addresses from the parameters defined by {Jerbil::Config}, allowing
208
- users to limit jerbil addresses, both to control which machines get polled and to speed
209
- up the search. The jerbil port is polled using the standard library TCPSocket interface
210
- with a timeout (standard library again). When the server finds another server it first
211
- does a minor security check (see below) and then obtains all of the services registered with
212
- that server and adds it to its service database.
213
-
214
222
  Jerbil is intended to be as reliable as possible - to survive any of the servers and
215
223
  their services leaving the network unexpectedly. If a local client attempts to connect
216
224
  to a remote service and fails, then the server will be asked to check with {Jerbil::Broker#service_missing?}.
@@ -228,6 +236,30 @@ but they keep track of their own pids instead of relying on daemon. To stop the
228
236
  an attempt is made to call the stop method, which cleans up with all the other servers,
229
237
  but failing that the pid is used to kill the server.
230
238
 
239
+ ### Server Discovery
240
+
241
+ Jerbil servers automatically connect to each other on a LAN to make their management
242
+ as easy as possible. They do this using brute force - polling each address on the network
243
+ until they find a server and then registering with it. This all takes time and to avoid
244
+ delaying the server itself, the discovery task is delegated to {Jerbil::Monitor}, which
245
+ is run in a sub-process by the sbin/jerbild script.
246
+
247
+ The {Jerbil::Monitor} class uses the {Jerbil::Servers.find_servers} class method to
248
+ search the network for any other servers. This method uses the NetAddr gem to create a
249
+ list of network addresses from the parameters defined by {Jerbil::Config}, allowing
250
+ users to limit jerbil addresses, both to control which machines get polled and to speed
251
+ up the search. The Jerbil port is polled using the standard library TCPSocket interface
252
+ with a timeout (standard library again). When the server finds another server it first
253
+ does a minor security check (see below) and then obtains all of the services registered with
254
+ that server and adds it to its service database.
255
+
256
+ To avoid missing any servers that may have been busy during the short period waited on
257
+ each port, the monitor process can loop round the discovery task multiple times (see
258
+ defaults in {Jerbil::Config}. There is also a delay between each cycle that can be
259
+ set in {Jeckyl::Config}. Overall, the parameters for the monitor task can be tuned
260
+ to ensure success on anything from a small subnet to a large network. The only thing
261
+ it cannot do is monitor more than one network.
262
+
231
263
  ### Services
232
264
 
233
265
  Services are created by inheriting the {JerbilService::Base} class:
@@ -303,7 +335,7 @@ event that an exception is raised during the daemonization process.
303
335
 
304
336
  ## Dependencies
305
337
 
306
- A ruby compiler - works with 1.8.7.
338
+ Tested on Ruby 1.9.3 and 2.0.0.
307
339
 
308
340
  Check the {file:Gemfile} for other dependencies.
309
341
 
@@ -326,7 +358,7 @@ See {file:History.txt} for a summary change history
326
358
 
327
359
  ## Copyright and Licence
328
360
 
329
- Copyright (c) 2012 Robert Sharp
361
+ Copyright (c) 2014 Robert Sharp
330
362
 
331
363
  This software is licensed under the terms defined in {file:LICENCE.rdoc}
332
364
 
@@ -1,6 +1,7 @@
1
1
  # Jerbil Testing
2
2
 
3
- Testing is generally through rspec, development/test versions of the Jerbil server, and service mocks.
3
+ Testing is generally through rspec, development/test versions of the Jerbil server, and service mocks.
4
+ Rspec 3.1.0 has been used for all tests
4
5
 
5
6
  ## Basic tests
6
7
 
data/bin/jerbil CHANGED
@@ -19,6 +19,7 @@
19
19
  #
20
20
 
21
21
  require 'optplus'
22
+ require 'optplus/IO'
22
23
  require 'jerbil'
23
24
  require 'jellog/proxy'
24
25
  require 'colored'
@@ -26,6 +27,8 @@ require 'socket'
26
27
 
27
28
  class Jerbs < Optplus::Parser
28
29
 
30
+ include Optplus::IO
31
+
29
32
  usage "[options] actions"
30
33
 
31
34
  description "Provide information on Jerbil servers and services"
@@ -45,7 +48,7 @@ class Jerbs < Optplus::Parser
45
48
  if FileTest.exists?(c) then
46
49
  set_option :config, c
47
50
  else
48
- message :fatal, "the config file given does not exist"
51
+ alert "the config file given does not exist"
49
52
  end
50
53
  end
51
54
 
@@ -67,79 +70,104 @@ class Jerbs < Optplus::Parser
67
70
  puts "Error: No config file #{config_file ? config_file : '/etc/jerbil/jerbil.rb'}".red.bold
68
71
  end
69
72
 
73
+
70
74
  describe :status, "show the status of the local server"
75
+ help :status, " jerbil status",
76
+ "",
77
+ "Display status information about the local Jerbil server, such as its version",
78
+ "and the time it was started"
79
+
71
80
  def status
72
- puts "Checking for local Jerbil server running in env: #{@config[:environment]}"
81
+ say "Checking for local Jerbil server running in env: #{@config[:environment]}"
73
82
  jerbs = @server.connect
74
83
  started = jerbs.started
75
- puts " Jerbil server found, version: #{jerbs.version}".green
76
- puts " Server has been up since #{started.strftime('%d %b %Y at %H:%M')}"
77
- puts " and has had #{jerbs.registrations.to_s} registrations"
78
- rescue Exception => err
79
- puts "Server did not respond: #{err.message}".red.bold
84
+ say_ok "Jerbil server found, version: #{jerbs.version}".green
85
+ say " Server has been up since #{started.strftime('%d %b %Y at %H:%M')}"
86
+ say " and has had #{jerbs.registrations.to_s} registrations."
87
+ rescue Jerbil::JerbilError
88
+ show_err "Jerbil Server Error"
89
+ rescue DRb::DRbError
90
+ show_err "Server did not respond"
80
91
  end
81
92
 
93
+
82
94
  describe :remotes, "list the remote servers on the network"
95
+ help :remotes, " jerbil remotes [-vV]",
96
+ "List remote servers and optionally verify the server is running.",
97
+ "Verbose listing does little atm but display the Ruby version."
98
+
83
99
  def remotes
84
- puts "Checking for remote Jerbil servers running in env: #{@config[:environment]}"
85
- begin
86
- jerbs = @server.connect
87
- remotes = jerbs.remote_servers
88
- remotes.each do |remote|
89
- if option?(:verify) then
90
- begin
91
- remote.connect.verify
92
- puts " #{remote.ident}".green
93
- rescue
94
- puts " #{remote.ident}".red
95
- end
96
- else
97
- puts " #{remote.ident}".cyan
98
- end #
99
- if option? :verbose then
100
- begin
101
- puts " Running under Ruby version: #{remote.connect.ruby_version}"
102
- rescue
103
- puts " No info on ruby version from this server"
104
- end
100
+ say "Checking for remote Jerbil servers running in env: #{@config[:environment]}"
101
+ jerbs = @server.connect
102
+ remotes = jerbs.remote_servers
103
+ remotes.each do |remote|
104
+ if option?(:verify) then
105
+ begin
106
+ remote.connect.verify
107
+ say_ok " #{remote.ident}"
108
+ rescue
109
+ say " #{remote.ident}".red
110
+ end
111
+ else
112
+ say " #{remote.ident}".cyan
113
+ end #
114
+ if option? :verbose then
115
+ begin
116
+ say " Jerbil server version: #{remote.version}"
117
+ say " Running under Ruby version: #{remote.connect.ruby_version}"
118
+ say " Remote server has been up since #{remote.started.strftime('%d %b %Y at %H:%M')}"
119
+ rescue
120
+ say " No info on ruby version from this server"
105
121
  end
106
122
  end
107
- rescue Exception => err
108
- puts " Server did not respond: #{err.message}".red.bold
109
123
  end
124
+ unless remotes && remotes.length > 0
125
+ # no remotes
126
+ warn "There are no remote servers registered at this time"
127
+ end
128
+
129
+ rescue Jerbil::JerbilError
130
+ show_err "Jerbil Server Error"
131
+ rescue DRb::DRbError
132
+ show_err "Jerbil Server did not respond"
133
+
110
134
  end
111
135
 
112
136
  describe :services, "list the services registered with Jerbil"
137
+ help :services, " jerbil services [-avV -h <hostname>]",
138
+ "Display the services registered with the local Jerbil Server.",
139
+ "By default, these are just the local services. To see services",
140
+ "on remote servers use the -a switch. You can also see just those",
141
+ "services on a given host with the -h switch. To verify that the services",
142
+ "are operating, use the -v switch."
143
+
113
144
  def services
114
145
  jerbs = @server.connect
115
146
  local_host = Socket.gethostname
116
147
  if option?(:all) then
117
- services = jerbs.get_all(true)
148
+ servers = jerbs.get_all_by_server
149
+ servers.each_pair do |name, services|
150
+ puts "Services for #{name}:"
151
+ display_services(services, jerbs)
152
+ end
153
+ unless servers && servers.length > 0
154
+ warn "There are no servers and therefore services registered with Jerbil"
155
+ end
156
+ return
118
157
  elsif option?(:host) then
119
158
  services = jerbs.find(host: get_option(:host), ignore_access: true)
120
159
  else
121
160
  services = jerbs.find(host: local_host, ignore_access: true)
122
161
  end
123
- services.each do |s|
124
- puts " #{s.name}[:#{s.env}]@#{s.host}:#{s.port}".cyan
125
- if option? :verbose then
126
- puts " started at: #{s.registered_at.strftime('%d/%m/%y %H:%M')}"
127
- puts " accessed #{s.access_count.to_s} times, last time at: #{s.accessed_at.strftime('%d/%m/%y %H:%M')}"
128
- end
129
- if option? :verify then
130
- if jerbs.service_missing?(s) then
131
- puts " #{s.ident} has failed and should be removed".red
132
- else
133
- puts " #{s.ident} responded".green
134
- end
135
- end
136
- end
137
-
138
- rescue Jerbil::JerbilServerError => err
139
- puts "Jerbil Server did not respond: #{err.message}".red.bold
162
+ display_services(services, jerbs)
163
+
164
+ rescue Jerbil::JerbilError
165
+ show_err "Jerbil Server Error"
166
+ rescue DRb::DRbError
167
+ show_err "Jerbil Server did not respond"
140
168
  end
141
169
 
142
- describe :secret, "generate a secret key for the Jerbil Servers"
170
+ describe :secret, "generate a random secret key for the Jerbil Servers"
143
171
  def secret
144
172
  puts "Paste the following into the config files for each server"
145
173
  key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)
@@ -157,6 +185,7 @@ class Jerbs < Optplus::Parser
157
185
  end
158
186
  end
159
187
 
188
+ # if hostname is not FQDN then get the FQDN
160
189
  def resolve_hostname(host)
161
190
  if host.split('.').length > 1 then
162
191
  return host
@@ -167,6 +196,36 @@ class Jerbs < Optplus::Parser
167
196
  end
168
197
  end
169
198
 
199
+ # helper method to display service information
200
+ def display_services(services, jerbs)
201
+ unless services && services.length > 0
202
+ warn "There are no services registered with Jerbil"
203
+ return false
204
+ end
205
+
206
+ services.each do |s|
207
+ puts " #{s.name}[:#{s.env}]@#{s.host}:#{s.port}".cyan
208
+ if option? :verbose then
209
+ puts " started at: #{s.registered_at.strftime('%d/%m/%y %H:%M')}"
210
+ puts " accessed #{s.access_count.to_s} times, last time at: #{s.accessed_at.strftime('%d/%m/%y %H:%M')}"
211
+ end
212
+ if option? :verify then
213
+ if jerbs.service_missing?(s) then
214
+ puts " #{s.ident} has failed and should be removed".red
215
+ else
216
+ puts " #{s.ident} responded".green
217
+ end
218
+ end
219
+ end
220
+
221
+ end # display_services
222
+
223
+ # helper method to show errors
224
+ def show_err(msg)
225
+ alert msg + ':'
226
+ puts " #{$!.message}"
227
+ end
228
+
170
229
  end
171
230
 
172
231
  Jerbs.run!