jerbil 1.2.2 → 1.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjBlMmZlMjU5N2FhNDY2NzIwOTJlYTNlMWUzMzUwZmI0MjIzMjZiOA==
5
+ data.tar.gz: !binary |-
6
+ MzBjYmIzY2Q1M2EzMjhjYTZlN2FmMDcxNzMzYjJhOGMyYWMwY2I0MA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OGIzZjRhY2IxZDdkMGYyNTI1MDE0ZjRjMjc5ZGQ2OTU2ZGU5ZjEyNWQwNDY3
10
+ ZjdjYmVmMDU5ZDIzOTdkYTc5MjczMGM0MmY3MmVjZWI3YmRjNDI1ZTY4NGE0
11
+ YzQ1ZDAyNGFjODNiZWNhMzM4MTAzNTNkMGExY2U2OTZiMjYxYjQ=
12
+ data.tar.gz: !binary |-
13
+ NDkyYmIxZWNlZDVhM2Y2NzgxOGNkYjQ5M2JkN2Y2ZDE5M2YxMDUyZDk1OTdm
14
+ YjhiMDM2MzMzZjQ4MmYyNGM2OWI5NmY3NThjMTc3NDMwZTdiNGE4ZWM2Mzg2
15
+ OGMyY2VkZWQyODJiMTI5OTFmODc5M2EyYWZkYmE2Y2ZmODYxOTk=
data/Bugs.rdoc CHANGED
@@ -1,66 +1,19 @@
1
1
  == Bugs
2
2
 
3
- ====31-Jan-2012
3
+ [jerbil-1.3.1 29-Aug-2013]
4
4
 
5
- * a client that does not respond to a verify can hang jerbil! Is it possible
6
- put a timeout on?
5
+ Need to update jerbil command to get rid of thor and improve what it does.
6
+ Consider Network Dependencies - where a service on one machine does not start
7
+ without a service on another or when a service is taken down on which others depend
8
+ then they are notified first, through Jerbil?
7
9
 
8
- 10-01-2012
10
+ [jerbil-1.2.3 06-June-2013]
9
11
 
10
- sclient will strip out log options when getting its own! Need to change this or add
11
- an option in Jellog to not strip them.
12
+ * If a server attempts to connect to another that is no longer working then the caller hangs.
12
13
 
13
- 01-Dec-2011
14
+ [jerbil-1.2.2 22-Nov-2012]
14
15
 
15
- JerbilService::Client should be relaxed about config options!
16
-
17
- Nov-2011
18
-
19
- Nasty race condition where remote server deletes registering service from its local
20
- server, so everyone knows about a service except the local server! (Should be fixed in 0.2.12)
21
-
22
- 09-Sep-2011
23
-
24
- There is no checking that services registered locally have the same hostname as the
25
- server. Should not be an issue, but did cause problems during testing.
26
-
27
- There is no way of directing a client or service to a particular jerbil server. Should
28
- only be relevant to testing, could add a :jerbil_config key to the options hash when calling
29
- get_server, which would always return nil if it had not been set anyway. (Addressed)
30
-
31
- 05-Sep-2011
32
-
33
- When a server assumes control of a missing service because the server is not there, it fails
34
- to delete its own copy! And when the missing server resumes, it cannot delete the un-deleted
35
- service because it does not have the right key for that service anymore.
36
-
37
- Colored success response for jerbl -v would be a big benefit
38
-
39
- 01-Aug-2011
40
-
41
- 1. service-missing is not working as expected. Needs to be tested to see what happens
42
- when a server is ungracefully removed. May need to change logic from removing services
43
- to removing servers. - See above
44
-
45
- 2. Need to add client config file for jerbil to avoid having readable files everywhere.
46
-
47
- 23-June-2011
48
-
49
- jerbil -V reports the number of times a service has been accessed through the local server.
50
- Would be good to share all counts across all servers somehow?
51
-
52
- 17-Apr-2011
53
-
54
- If you run jerbil -v on a remote server it appears to remove a service but the removal fails.
55
- This is because it tries to remove the service locally. Also, if a server disappears then
56
- the other servers still think the service is available. They need to remove the service manually if
57
- that is the case!
58
-
59
- Fixed in 0.1.0
60
- ------
61
- 17-May-2011
62
-
63
- Would be good to hide the key check in a private function: check_key(key) rather than
64
- expose the underlying mechanism
65
-
66
- Also change key to pkey for private key parameters
16
+ * Supervisor#stop does not call stop_callback in the scope of the connected session
17
+ so the service is not stopped as it should be.
18
+
19
+ Appears to be fixed.
data/Gemfile CHANGED
@@ -9,4 +9,6 @@ gem 'daemons'
9
9
  # jerbil-related utilities
10
10
  gem 'jellog', '>=1.0.14' # for logging
11
11
  gem 'jeckyl', '>=0.2.7' # for config files
12
- gem 'jeni', '>=0.2.3' # for installation
12
+ gem 'jeni', '>=0.2.5' # for installation
13
+
14
+ gem 'optplus', '>=0.0.2'
data/History.txt CHANGED
@@ -4,6 +4,55 @@
4
4
 
5
5
  ==History
6
6
 
7
+ [jerbil-1.3.3 03-Sep-2013]
8
+
9
+ Ensure jerbil methods are called on the server and not the server record.
10
+
11
+ [jerbil-1.3.2 03-Sep-2013]
12
+
13
+ Introduce Optplus version of the bin/jerbil command and add a couple of information
14
+ methods to the server in support.
15
+
16
+ [jerbil-1.3.1 29-Aug-2013]
17
+
18
+ Fix minor error in runscript (status)
19
+
20
+ [jerbil-1.3.0 29-Aug-2013]
21
+
22
+ First release with properly multiplexed runscript files
23
+
24
+ [jerbil-1.2.10 28-Aug-2013]
25
+
26
+ Add the export of LANG to support encodings
27
+
28
+ [jerbil-1.2.9 28-Aug-2013]
29
+
30
+ further changes to runscripts to not fiddle with PATH etc
31
+
32
+ [jerbil-1.2.8 28-Aug-2013]
33
+
34
+ Various changes to runscripts to cope with /usr/local and to use checkpath
35
+
36
+ [jerbil-1.2.7 27-Aug-2013]
37
+
38
+ Added log entry to record RUBY_VERSION for a service
39
+
40
+ [jerbil-1.2.6 23-Aug-2013]
41
+
42
+ Ensure that Jerbil is 1.9 compliant and ready to go
43
+
44
+ [jerbil-1.2.5 16-Aug-2013]
45
+
46
+ Use /bin/su for all init.d actions (stop and status)
47
+
48
+ [jerbil-1.2.4 03-Apr-2013]
49
+
50
+ Suppress client messages about method strings and symbols
51
+
52
+ [jerbil-1.2.3 03-Apr-2013]
53
+
54
+ Add chmod to creation of /var/run/jerbil in jerbil initscript.
55
+
7
56
  [jerbil-1.2.2 21-Nov-2012]
8
57
 
9
58
  Add proper home for jerbil user in jerbil-install. Add guidance on logging to READMEs.
data/README.md CHANGED
@@ -39,6 +39,8 @@ of [Jeni](https://github.com/osburn-sharp/jeni):
39
39
 
40
40
  This will install various files over and above those installed by the gem, including configuration files,
41
41
  runscripts, and sbin wrappers for the jerbil server and for services that use the server.
42
+ By default, Jerbil will install start-up scripts etc into /usr/local/sbin, but this can be
43
+ changed to /usr/sbin by adding the -u option or the -t option.
42
44
  Use the -p switch to pretend and see if everything works OK. Jerbil assumes there is a
43
45
  user 'jerbil' that will run the server process etc, so if there is no user 'jerbil' then
44
46
  this script will create one.
@@ -127,15 +129,18 @@ the latter command works on Gentoo at least.
127
129
 
128
130
  You can also check if the server is working using:
129
131
 
130
- # /usr/sbin/jerbil-status -V
131
- or
132
132
  # /etc/init.d/jerbild status
133
133
 
134
134
  To stop the server:
135
135
 
136
- # /usr/sbin/jerbil-stop
137
- or
138
136
  # /etc/init.d/jerbild stop
137
+
138
+ If your distro does not support runscripts like this, then you can start, stop and test status
139
+ manually using:
140
+
141
+ # /usr/local/sbin/jerbild
142
+ # /usr/local/sbin/jerbil-status
143
+ # /usr/local/sbin/jerbil-stop
139
144
 
140
145
  Further details of all these commands can be obtained with the -h or --help option
141
146
 
data/README_SERVICES.md CHANGED
@@ -342,49 +342,69 @@ Its convenient to start a service automatically, and Jerbil tries to make this e
342
342
  However, what is on offer will probably only work out of the box for Gentoo.
343
343
 
344
344
  There is only one runscript needed and if you followed the installation instructions
345
- in {file:README.md the readme file} then this will already be installed as /etc/init.d/jserviced.
345
+ in {file:README.md the readme file} then this will already be installed as /etc/init.d/jerbil
346
+ (not jerbild which is the jerbil server itself). Notice that Jerbil Services can be
347
+ managed using a "multiplexed" runscript. The runscript for each service is a link
348
+ to a common runscript, there is a config file for each service and another common
349
+ file for all services.
350
+
346
351
  To set up a service involves the following:
347
352
 
348
- * create a link to /etc/init.d/jserviced for your service, e.g. /etc/init.d/myserviced
349
- * create a copy of /etc/conf.d/jserviced for your service, e.g. /etc/conf.d/myserviced.
350
- Ensure these two files have the same name.
353
+ * create a link to /etc/init.d/jerbil for your service, e.g. /etc/init.d/jerbil.my_service
354
+ * create a copy of /etc/conf.d/jerbil.service for your service, e.g. /etc/conf.d/jerbil.my_service
355
+ Ensure these two files (init and conf) have the same name.
351
356
  * edit the conf.d file as required.
352
- * start the service: /etc/init.d/myserviced start
353
- * add the service to your default runscripts: rc-update add myserviced default
357
+ * start the service: /etc/init.d/jerbil.my_service start
358
+ * add the service to your default runscripts: rc-update add jerbil.my_service default
354
359
 
355
- The variables defined in the conf.d file are:
360
+ The variables defined in the main conf.d file (/etc/conf.d/jerbil) are:
356
361
 
357
362
  * NO_DAEMON - set to true to run the service in the foreground, usually to debug it.
358
363
  Defaults to false.
359
364
  * NO_SYSLOG - suppress messages that would normally be sent to syslog, again usually
360
365
  for debug purposes. Defaults to false.
361
366
  * CONF_FILE - path to the config file for this service. Defaults to whatever the default
362
- location is for Jeckyl (e.g. /etc/jermine/myservice.rb)
367
+ location is for Jeckyl (e.g. /etc/jerbil/my_service.rb)
363
368
  * LOG_DAEMON - log the output from the daemon, which covers the startup process before
364
369
  the service starts logging itself. By default this will be logged to a file named
365
- after the service with the suffix _sd added, e.g. /var/log/jermine/myservice_sd.log
370
+ after the service with the suffix _sd added, e.g. /var/log/jerbil/my_service_sd.log
366
371
  Defaults to false
367
372
  * VERBOSE - output more information during the startup process. This does not affect
368
373
  the level of logging for the service itself
369
- * SERVICE_NAME - by default the service name will be determined from the runscript.
370
- But if, like me, you always seem to want a "d" on the end, then use this to ensure
371
- the script picks up the right service, e.g. SERVICE_NAME="myservice"
374
+ * SBIN_PATH - the path to the directory where the service is located. This will be set
375
+ to /usr/local/sbin and can be changed to whatever your default location happens to
376
+ be.
372
377
  * SERVICE_USER - by default, the service user will be a user created when Jerbil was
373
- installed (jermine). Change it here if you want someone else. See below for details.
374
- * USES - enter any services that this service uses. Make sure each service is on a
375
- separate line. e.g. 'USES="logger' on one line and 'net"' on the next. See the example
376
- in /etc/conf.d/jserviced.
377
- * NEEDS - enter any services that this service needs. Make sure this is at least "jerbild".
378
- As above, make it one entry per line.
378
+ installed (jerbil). Change it here if you want someone else. See below for details.
379
+ * Universal runscript dependencies are defined by default using rc_use and rc_need.
380
+
381
+ For each service it is possible to override the above variables and the following
382
+
383
+ * SERVICE_NAME - by default the service name will be determined from the runscript.
384
+ For example, for my_service the runscript should be called jerbil.my_service.
379
385
  * DESCRIPTION - a one line description that will be displayed during start/stop operations.
380
386
 
381
- All services are super-user'd to a given user for safety within the runscript. By default this is jermine
387
+ Note if you need to add a dependency (see 'man runscript' for details) then you will
388
+ need to preserve existing values as well, either explicitly or by adding the variable
389
+ to any new definition:
390
+
391
+ rc_use="logger net atd"
392
+ rc_need="postgres ${rc_need}"
393
+
394
+ All services are super-user'd to a given user for safety within the runscript. By default this is jerbil
382
395
  but you can set it to another user as above.
383
396
 
384
- When setting USES and NEEDS remember that services defined as needed will restart this
397
+ When setting use and need dependencies remember that services defined as needed will restart this
385
398
  service when they are restarted. Services that are just used do not restart this service
386
399
  but will be started before it.
387
400
 
401
+ Finally, the generic runscript does not preserve the environment through the su command and
402
+ the path will be very limited (by runscript), which is why SBIN_PATH is required. It
403
+ does set one environment variable on start with is LANG and that is to help ruby 1.9 applications
404
+ that have complex encoding demands. If you need more variables to be set it is suggested
405
+ that you create a bespoke runscript and set them up as part of the su command. Inheriting
406
+ the environment and passing in a wider path may present security risks.
407
+
388
408
  ## Errors and Exceptions
389
409
 
390
410
  If you define your parameters using Jeckyl and {JerbilService::Config} and check them
data/bin/jerbil CHANGED
@@ -1,12 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  #
3
3
  #
4
- # = Jerbil command line utility
5
4
  #
6
- # == control and display jerbil related info
5
+ # = Jerbil command line
6
+ #
7
+ # == useful things to do with Jerbil
7
8
  #
8
9
  # Author:: Robert Sharp
9
- # Copyright:: Copyright (c) 2011 Robert Sharp
10
+ # Copyright:: Copyright (c) 2013 Robert Sharp
10
11
  # License:: Open Software Licence v3.0
11
12
  #
12
13
  # This software is licensed for use under the Open Software Licence v. 3.0
@@ -14,49 +15,158 @@
14
15
  # and in the file copyright.txt. Under the terms of this licence, all derivative works
15
16
  # must themselves be licensed under the Open Software Licence v. 3.0
16
17
  #
17
- # Trial using Thor
18
+ #
18
19
  #
19
- require 'rubygems'
20
- require 'thor'
21
- require 'thor/group'
20
+
21
+ require 'optplus'
22
22
  require 'jerbil'
23
+ require 'jellog/proxy'
23
24
  require 'colored'
25
+ require 'socket'
24
26
 
27
+ class Jerbs < Optplus::Parser
28
+
29
+ usage "[options] actions"
30
+
31
+ description "Provide information on Jerbil servers and services"
32
+
33
+ def options(opts)
34
+
35
+ opts.on('-a', '--all', 'show all servers or services') do |a|
36
+ set_option :all, a
37
+ end
38
+
39
+ opts.on('-H', '--host STRING', String, 'show services on given host') do |h|
40
+ hostname = resolve_hostname(h)
41
+ set_option :host, hostname
42
+ end
43
+
44
+ opts.on('-c', '--config [FILE]', String, 'use the given config file') do |c|
45
+ if FileTest.exists?(c) then
46
+ set_option :config, c
47
+ else
48
+ message :fatal, "the config file given does not exist"
49
+ end
50
+ end
51
+
52
+ opts.on('-v', '--verify', 'verify the connections') do |c|
53
+ set_option :verify, c
54
+ end
55
+
56
+ debug_option(opts)
57
+
58
+ verbose_option(opts)
25
59
 
26
- require 'jerbil/thor/server'
27
- require 'jerbil/thor/service'
28
-
29
-
30
-
31
- # the main thor handler
32
- class Jerbs < Thor
33
-
34
- #class_option :verbose, :default=>false, :aliases=>'-V', :desc=>'print more information'
35
-
36
- desc "test", "This is just to test things"
37
- method_option :debug, :aliases=>'-D', :desc=>'display debug information'
38
- def test
39
- puts "Hello World"
40
- if options[:debug] then
41
- puts "Debugging..."
42
- puts " Load Path:"
43
- $LOAD_PATH.each do |lpath|
44
- puts " #{lpath.to_s}"
60
+ end
61
+
62
+ def before_actions
63
+ @logger = Jellog::ProxyLogger.new("Jerbil")
64
+ @config = Jerbil.get_config(get_option(:config))
65
+ @server = Jerbil::Servers.get_local_server(@config[:environment])
66
+ rescue Jeckyl::ConfigFileMissing
67
+ puts "Error: No config file #{config_file ? config_file : '/etc/jerbil/jerbil.rb'}".red.bold
68
+ end
69
+
70
+ describe :status, "show the status of the local server"
71
+ def status
72
+ puts "Checking for local Jerbil server running in env: #{@config[:environment]}"
73
+ jerbs = @server.connect
74
+ 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
80
+ end
81
+
82
+ describe :remotes, "list the remote servers on the network"
83
+ 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
105
+ end
45
106
  end
107
+ rescue Exception => err
108
+ puts " Server did not respond: #{err.message}".red.bold
46
109
  end
47
110
  end
48
111
 
112
+ describe :services, "list the services registered with Jerbil"
113
+ def services
114
+ jerbs = @server.connect
115
+ local_host = Socket.gethostname
116
+ if option?(:all) then
117
+ services = jerbs.get_all(true)
118
+ elsif option?(:host) then
119
+ services = jerbs.find(host: get_option(:host), ignore_access: true)
120
+ else
121
+ services = jerbs.find(host: local_host, ignore_access: true)
122
+ 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
140
+ end
49
141
 
50
- register Server, :server, "server", "show information about jerbil servers"
142
+ describe :secret, "generate a secret key for the Jerbil Servers"
143
+ def secret
144
+ puts "Paste the following into the config files for each server"
145
+ key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)
146
+ puts 'secret "' + key + '"'
147
+ end
51
148
 
52
-
53
- register Service, :service, "service", "show information about registered services"
149
+ describe :readme, 'Display the Jerbil Readme file by whatever means is best'
150
+ def readme
151
+ gem_spec = Gem::Specification.find_by_name('jerbil')
152
+ readme_path = File.join(gem_spec.gem_dir, 'README.md')
153
+ if FileTest.exists?('/usr/bin/markdown_py') then
154
+ exec "markdown_py #{readme_path} | lynx -stdin"
155
+ else
156
+ exec "less #{readme_path}"
157
+ end
158
+ end
54
159
 
55
- map "services"=>"service"
56
-
57
- # use separate jeni installer
58
- #register Installer, :install, "install", "install jerbil on local machine"
160
+ def resolve_hostname(host)
161
+ if host.split('.').length > 1 then
162
+ return host
163
+ else
164
+ myhost = Socket.gethostname.split('.')
165
+ myhost[0] = host
166
+ return myhost.join('.')
167
+ end
168
+ end
59
169
 
60
170
  end
61
171
 
62
- Jerbs.start
172
+ Jerbs.run!