jerbil 1.3.3 → 1.4.5

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.
@@ -38,7 +38,7 @@ Jeni::Installer.new_from_gem('jerbil') do |jeni|
38
38
 
39
39
 
40
40
  jeni.file('etc/jerbil/jerbil.rb', '/etc/jerbil/jerbil.rb', :chown=>'jerbil', :chgrp=>'jerbil', :chmod=>0640)
41
- jeni.file('etc/jerbil/jerbil-client.rb', '/etc/jerbil/jerbil-client.rb', :chown=>'jerbil', :chgrp=>'jerbil', :chmod=>0640)
41
+ jeni.file('etc/jerbil/jerbil-test.rb', '/etc/jerbil/jerbil-test.rb', :chown=>'jerbil', :chgrp=>'jerbil', :chmod=>0640)
42
42
 
43
43
  # configuration file to run the service
44
44
  jeni.file('etc/conf.d/jerbild', '/etc/conf.d/jerbild')
@@ -0,0 +1,83 @@
1
+ #
2
+ # Configuration Options for: Jelly::Options
3
+ #
4
+
5
+ # Number of log files to retain at any time, between 0 and 20
6
+ #log_rotation 2
7
+
8
+ # Location for Jelly (logging utility) to save log files
9
+ #log_dir "/var/log/jerbil"
10
+
11
+ # Set the string to be used for marking the log with logger.mark
12
+ #log_mark " ===== Mark ====="
13
+
14
+ # Reset the logfile when starting logging by setting to true, otherwise append to
15
+ # existing log
16
+ #log_reset false
17
+
18
+ # Setting to true (the default) will flush log messages immediately, which is useful if you
19
+ # need to monitor logs dynamically
20
+ #log_sync true
21
+
22
+ # Size of a log file (in MB) before switching to the next log, upto 20 MB
23
+ #log_length 1
24
+
25
+ # Format string for time stamps. Needs to be a string that is recognised by String.strftime
26
+ # Any characters not recognised by strftime will be printed verbatim, which may not be what you want
27
+ #log_date_time_format "%Y-%m-%d %H:%M:%S"
28
+
29
+ # Controls the amount of logging done by Jelly
30
+ #
31
+ # * :system - standard message, plus log to syslog
32
+ # * :verbose - more generous logging to help resolve problems
33
+ # * :debug - usually used only for resolving problems during development
34
+ #
35
+ #log_level :system
36
+
37
+ # Set to false to suppress colourful logging. Default colours can be changed by calling
38
+ # colours= method
39
+ #log_coloured true
40
+
41
+ #
42
+ # Configuration Options for: JerbilService::Config
43
+ #
44
+
45
+ # private key dir used to authenticate privileged users
46
+ #key_dir "/var/run/jerbil"
47
+
48
+ # Set the default environment for service commands etc.
49
+ #
50
+ # Can be one of :prod, :test, :dev
51
+ #environment :prod
52
+
53
+ # Set this only to use a Jerbil Server that is not running in the production environment
54
+ #jerbil_env
55
+
56
+ # directory used to store the daemons pid to assist in stopping reluctant servers
57
+ #pid_dir "/var/run/jerbil"
58
+
59
+ #
60
+ # Configuration Options for: Jerbil::Config
61
+ #
62
+
63
+ # A secret key available to all Jerbil Servers and used to authenticate the initial registration.
64
+ # If security is an issue, ensure that this config file is readable only be trusted users
65
+ secret "hK78l/z1mIDBOs+/Qx2q7k5beExChmdc3tpw81qTBNLmcQknRrY93oHzIAd3DNo2"
66
+
67
+ # A valid netmask for the hosts to search using the above net address. This should be
68
+ # between 24 (a class C network) and 30, beyound which its not much of a network. If you only have a few
69
+ # hosts it will be easier to restrict them to a small subnet.
70
+ #
71
+ # To find out more about netmasks, go to [UnixWiz](http://www.unixwiz.net/techtips/netmask-ref.html).
72
+ #net_mask 26
73
+
74
+ # Provide a timeout when searching for jerbil servers on the net during startup.
75
+ # Depending on the size of the net mask this timeout may make the search long.
76
+ # The default should work in most cases
77
+ #scan_timeout 0.1
78
+
79
+ # A valid IPv4 address for the LAN on which the servers will operate.
80
+ # Note that the broker uses this address to search for all servers.
81
+ # Therefore a large range will take a long time to search. Set the net_mask to limit this.
82
+ #net_address "192.168.0.1"
83
+
@@ -0,0 +1,105 @@
1
+ #
2
+ # Configuration Options for: Jellog::Config
3
+ #
4
+
5
+ # Path to a writeable directory where Jellog will save log files.
6
+ #log_dir "/var/log/jerbil"
7
+
8
+ # Controls the amount of logging done by Jellog
9
+ #
10
+ # * :system - standard message, plus log to syslog
11
+ # * :verbose - more generous logging to help resolve problems
12
+ # * :debug - usually used only for resolving problems during development
13
+ #
14
+ log_level :debug
15
+
16
+ # Number of log files to retain at any time, between 0 and 20
17
+ #log_rotation 2
18
+
19
+ # Size of a log file (in MB) before switching to the next log, upto 20 MB
20
+ #log_length 1
21
+
22
+ # Reset the logfile when starting logging by setting to true, otherwise append to
23
+ # existing log
24
+ #log_reset false
25
+
26
+ # Set to false to suppress colourful logging. Default colours can be changed by calling
27
+ # #colours= method
28
+ #log_coloured true
29
+
30
+ # Format string for time stamps. Needs to be a string that is recognised by String#strftime
31
+ # Any characters not recognised by strftime will be printed verbatim, which may not be what you want
32
+ #log_date_time_format "%Y-%m-%d %H:%M:%S"
33
+
34
+ # Setting to true (the default) will flush log messages immediately, which is useful if you
35
+ # need to monitor logs dynamically
36
+ #log_sync true
37
+
38
+ # Set the string to be used for marking the log with logger.mark
39
+ #log_mark " ===== Mark ====="
40
+
41
+ # Set to true to prevent system log calls from logging to syslog as well
42
+ #disable_syslog false
43
+
44
+ #
45
+ # Configuration Options for: JerbilService::Config
46
+ #
47
+
48
+ # Set the environment for the service to run in.
49
+ #
50
+ # Can be one of the following:
51
+ # :prod - for productionised services in use across a network
52
+ # :test - for testing a release candidate, e.g. also across the network
53
+ # :dev - for developing the next release
54
+ #
55
+ # Services can be running in all three environments at the same time. Clients
56
+ # will need to use the appropriate config file to connect with each environment.
57
+ environment :test
58
+
59
+ # a writable directory where Jerbil stores a private key for each service.
60
+ # This key is used to authenticate systems operations, such as stopping the service.
61
+ # It is not used for client interactions, which can require a separate service key.
62
+ #key_dir "/var/run/jerbil"
63
+
64
+ # A writable directory used to store the pid to assist in stopping reluctant servers
65
+ #pid_dir "/var/run/jerbil"
66
+
67
+ # Set this only to use a Jerbil Server that is not running in the production environment
68
+ #jerbil_env
69
+
70
+ #
71
+ # Configuration Options for: Jerbil::Config
72
+ #
73
+
74
+ # A valid IPv4 address for the LAN on which the servers will operate.
75
+ # Note that the broker uses this address to search for all servers.
76
+ # Therefore a large range will take a long time to search. Set the net_mask to limit this.
77
+ #net_address "192.168.0.1"
78
+
79
+ # A valid netmask for the hosts to search using the above net address. This should be
80
+ # between 24 (a class C network) and 30, beyound which its not much of a network. If you only have a few
81
+ # hosts it will be easier to restrict them to a small subnet.
82
+ #
83
+ # To find out more about netmasks, go to [UnixWiz](http://www.unixwiz.net/techtips/netmask-ref.html).
84
+ #net_mask 26
85
+
86
+ # Provide a timeout in seconds when searching for jerbil servers on the net during startup.
87
+ # Depending on the size of the net mask this timeout may make the search long.
88
+ # The default should work in most cases
89
+ #scan_timeout 0.1
90
+
91
+ # Define how many times the monitor process will check for other servers
92
+ # at start up. Limited to at least once and at most 10 times. Probably is not need
93
+ # to check more than 3 times unless you set a very short scan timeout.
94
+ #check_count 3
95
+
96
+ # Define the delay between successive checks carried out by the monitor at start up.
97
+ # Setting it to 0 will cause the checks to be completed without delay. The upper limit is
98
+ # an hour for no particular reason. Default should work for most cases. Could be quicker on smaller
99
+ # nets with fewer machines to check each time.
100
+ #loop_time 30
101
+
102
+ # A secret key available to all Jerbil Servers and used to authenticate the initial registration.
103
+ # If security is an issue, ensure that this config file is readable only be trusted users
104
+ secret "Change Me!"
105
+
@@ -1,68 +1,80 @@
1
1
  #
2
- # Configuration Options for: Jelly::Options
2
+ # Configuration Options for: Jellog::Config
3
3
  #
4
4
 
5
+ # Path to a writeable directory where Jellog will save log files.
6
+ #log_dir "/var/log/jerbil"
7
+
8
+ # Controls the amount of logging done by Jellog
9
+ #
10
+ # * :system - standard message, plus log to syslog
11
+ # * :verbose - more generous logging to help resolve problems
12
+ # * :debug - usually used only for resolving problems during development
13
+ #
14
+ #log_level :system
15
+
5
16
  # Number of log files to retain at any time, between 0 and 20
6
17
  #log_rotation 2
7
18
 
8
- # Location for Jelly (logging utility) to save log files
9
- #log_dir "/var/log/jerbil"
10
-
11
- # Set the string to be used for marking the log with logger.mark
12
- #log_mark " ===== Mark ====="
19
+ # Size of a log file (in MB) before switching to the next log, upto 20 MB
20
+ #log_length 1
13
21
 
14
22
  # Reset the logfile when starting logging by setting to true, otherwise append to
15
23
  # existing log
16
24
  #log_reset false
17
25
 
18
- # Setting to true (the default) will flush log messages immediately, which is useful if you
19
- # need to monitor logs dynamically
20
- #log_sync true
21
-
22
- # Size of a log file (in MB) before switching to the next log, upto 20 MB
23
- #log_length 1
26
+ # Set to false to suppress colourful logging. Default colours can be changed by calling
27
+ # #colours= method
28
+ #log_coloured true
24
29
 
25
- # Format string for time stamps. Needs to be a string that is recognised by String.strftime
30
+ # Format string for time stamps. Needs to be a string that is recognised by String#strftime
26
31
  # Any characters not recognised by strftime will be printed verbatim, which may not be what you want
27
32
  #log_date_time_format "%Y-%m-%d %H:%M:%S"
28
33
 
29
- # Controls the amount of logging done by Jelly
30
- #
31
- # * :system - standard message, plus log to syslog
32
- # * :verbose - more generous logging to help resolve problems
33
- # * :debug - usually used only for resolving problems during development
34
- #
35
- #log_level :system
34
+ # Setting to true (the default) will flush log messages immediately, which is useful if you
35
+ # need to monitor logs dynamically
36
+ #log_sync true
36
37
 
37
- # Set to false to suppress colourful logging. Default colours can be changed by calling
38
- # colours= method
39
- #log_coloured true
38
+ # Set the string to be used for marking the log with logger.mark
39
+ #log_mark " ===== Mark ====="
40
+
41
+ # Set to true to prevent system log calls from logging to syslog as well
42
+ #disable_syslog false
40
43
 
41
44
  #
42
45
  # Configuration Options for: JerbilService::Config
43
46
  #
44
47
 
45
- # private key dir used to authenticate privileged users
46
- #key_dir "/var/run/jerbil"
47
-
48
- # Set the default environment for service commands etc.
48
+ # Set the environment for the service to run in.
49
+ #
50
+ # Can be one of the following:
51
+ # :prod - for productionised services in use across a network
52
+ # :test - for testing a release candidate, e.g. also across the network
53
+ # :dev - for developing the next release
49
54
  #
50
- # Can be one of :prod, :test, :dev
55
+ # Services can be running in all three environments at the same time. Clients
56
+ # will need to use the appropriate config file to connect with each environment.
51
57
  #environment :prod
52
58
 
53
- # Set this only to use a Jerbil Server that is not running in the production environment
54
- #jerbil_env
59
+ # a writable directory where Jerbil stores a private key for each service.
60
+ # This key is used to authenticate systems operations, such as stopping the service.
61
+ # It is not used for client interactions, which can require a separate service key.
62
+ #key_dir "/var/run/jerbil"
55
63
 
56
- # directory used to store the daemons pid to assist in stopping reluctant servers
64
+ # A writable directory used to store the pid to assist in stopping reluctant servers
57
65
  #pid_dir "/var/run/jerbil"
58
66
 
67
+ # Set this only to use a Jerbil Server that is not running in the production environment
68
+ #jerbil_env
69
+
59
70
  #
60
71
  # Configuration Options for: Jerbil::Config
61
72
  #
62
73
 
63
- # A secret key available to all Jerbil Servers and used to authenticate the initial registration.
64
- # If security is an issue, ensure that this config file is readable only be trusted users
65
- secret "hK78l/z1mIDBOs+/Qx2q7k5beExChmdc3tpw81qTBNLmcQknRrY93oHzIAd3DNo2"
74
+ # A valid IPv4 address for the LAN on which the servers will operate.
75
+ # Note that the broker uses this address to search for all servers.
76
+ # Therefore a large range will take a long time to search. Set the net_mask to limit this.
77
+ #net_address "192.168.0.1"
66
78
 
67
79
  # A valid netmask for the hosts to search using the above net address. This should be
68
80
  # between 24 (a class C network) and 30, beyound which its not much of a network. If you only have a few
@@ -71,13 +83,23 @@ secret "hK78l/z1mIDBOs+/Qx2q7k5beExChmdc3tpw81qTBNLmcQknRrY93oHzIAd3DNo2"
71
83
  # To find out more about netmasks, go to [UnixWiz](http://www.unixwiz.net/techtips/netmask-ref.html).
72
84
  #net_mask 26
73
85
 
74
- # Provide a timeout when searching for jerbil servers on the net during startup.
86
+ # Provide a timeout in seconds when searching for jerbil servers on the net during startup.
75
87
  # Depending on the size of the net mask this timeout may make the search long.
76
88
  # The default should work in most cases
77
89
  #scan_timeout 0.1
78
90
 
79
- # A valid IPv4 address for the LAN on which the servers will operate.
80
- # Note that the broker uses this address to search for all servers.
81
- # Therefore a large range will take a long time to search. Set the net_mask to limit this.
82
- #net_address "192.168.0.1"
91
+ # Define how many times the monitor process will check for other servers
92
+ # at start up. Limited to at least once and at most 10 times. Probably is not need
93
+ # to check more than 3 times unless you set a very short scan timeout.
94
+ #check_count 3
95
+
96
+ # Define the delay between successive checks carried out by the monitor at start up.
97
+ # Setting it to 0 will cause the checks to be completed without delay. The upper limit is
98
+ # an hour for no particular reason. Default should work for most cases. Could be quicker on smaller
99
+ # nets with fewer machines to check each time.
100
+ #loop_time 30
101
+
102
+ # A secret key available to all Jerbil Servers and used to authenticate the initial registration.
103
+ # If security is an issue, ensure that this config file is readable only be trusted users
104
+ secret "Change Me!"
83
105
 
@@ -103,21 +103,24 @@ module Jerbil
103
103
  @remote_store = Array.new
104
104
 
105
105
  # create a jellog logger that continues any previous log and keeps the last 5 log files
106
- app_name = "Jerbil-#{options[:environment].to_s}"
107
- log_opts = Jellog::Logger.get_options(options)
108
- @logger = Jellog::Logger.new(app_name, log_opts)
106
+ @app_name = "Jerbil-#{options[:environment].to_s}"
107
+ @log_opts = Jellog::Config.intersection(options)
108
+ #log_opts = @log_opts.dup
109
+ @logger = Jellog::Logger.new(@app_name, @log_opts)
109
110
  @logger.mark
110
111
  @logger.debug "Started the Logger for Jerbil"
112
+ @logger.debug "Saved logger options: #{@log_opts.inspect}"
111
113
 
112
114
 
113
115
  # some statistical data
114
116
  @started = Time.now
115
117
  @registrations = 0
116
118
  @logger.verbose("Searching for remote servers")
117
- network_servers = Jerbil::Servers.find_servers(@env, options[:net_address], options[:net_mask], options[:scan_timeout])
118
- @logger.verbose("Found #{@remote_servers.length} remote servers")
119
+ network_servers = [] #Jerbil::Servers.find_servers(@env, options[:net_address], options[:net_mask], options[:scan_timeout])
120
+ #@logger.verbose("Found #{@remote_servers.length} remote servers")
119
121
 
120
122
  # now loop round the remote servers to see if any are there
123
+ # DO NOTHING cos its an empty array!
121
124
  network_servers.each do |remote_server|
122
125
  rjerbil = remote_server.connect
123
126
  unless rjerbil.nil?
@@ -153,10 +156,21 @@ module Jerbil
153
156
  @logger.debug " #{rs.fqdn}: #{rs.key}"
154
157
  end
155
158
 
159
+ #@logger.verbose "Closing logger temporarily"
160
+ #@logger.close
161
+
156
162
  rescue => jerr
157
163
  @logger.exception(jerr)
158
164
  raise
159
165
  end
166
+
167
+ # restart the logger on the other side of daemonising it
168
+ #
169
+ # NOT NEEDED!
170
+ def restart_logger
171
+ @logger = Jellog::Logger.new(@app_name, @log_opts)
172
+ @logger.debug "Restarted Logger"
173
+ end
160
174
 
161
175
  # date/time at which the server was started
162
176
  attr_reader :started
@@ -370,6 +384,18 @@ module Jerbil
370
384
  def get_all(ignore_access=false)
371
385
  self.find(:ignore_access => ignore_access)
372
386
  end
387
+
388
+ def get_all_by_server
389
+ services = self.find(ignore_access: true)
390
+ servers = Hash.new
391
+ services.each do |serv|
392
+ unless servers.has_key?(serv.host)
393
+ servers[serv.host] = Array.new
394
+ end
395
+ servers[serv.host] << serv
396
+ end
397
+ return servers
398
+ end
373
399
 
374
400
  # Checks for a potentially missing service and removes it if it cannot be found.
375
401
  #
@@ -470,7 +496,7 @@ module Jerbil
470
496
  @remote_servers.each do |rserver|
471
497
  begin
472
498
  rjerbil = rserver.connect
473
- @logger.verbose("Closing connection to; #{rserver.ident}")
499
+ @logger.verbose("Closing connection to: #{rserver.ident}")
474
500
  rjerbil.detach_server(rserver.key, @local)
475
501
  rescue ServerConnectError, DRb::DRbConnError
476
502
  @logger.error("Failed to connect to #{rserver.ident}")
@@ -600,12 +626,18 @@ module Jerbil
600
626
  # @param [String] my_key being the key of the server being called
601
627
  # @param [Server] server being the record for the remote server that is detaching
602
628
  def detach_server(my_key, server)
603
- @logger.verbose("About to detach a remote server: #{server.ident}")
604
629
 
605
630
  unless @private_key == my_key
606
- @logger.warn("close_remote_server: incorrect key: #{my_key}")
607
- return true
631
+ @logger.warn("Detaching remote server: incorrect key: #{my_key}")
632
+ return false
608
633
  end
634
+
635
+ unless @remote_servers.include?(server)
636
+ @logger.warn "Detaching remote server: server not known: #{server.ident}"
637
+ return false
638
+ end
639
+
640
+ @logger.verbose("About to detach a remote server: #{server.ident}")
609
641
  @remote_store.delete_if {|s| s.host == server.fqdn}
610
642
  @remote_servers.delete(server)
611
643
  @logger.info("Detached server: #{server.ident}")
@@ -50,13 +50,30 @@ module Jerbil
50
50
 
51
51
  def configure_scan_timeout(tim)
52
52
  default 0.1
53
- comment "Provide a timeout when searching for jerbil servers on the net during startup.",
53
+ comment "Provide a timeout in seconds when searching for jerbil servers on the net during startup.",
54
54
  "Depending on the size of the net mask this timeout may make the search long.",
55
55
  "The default should work in most cases"
56
56
 
57
57
  a_type_of(tim, Numeric)
58
58
  end
59
59
 
60
+ def configure_check_count(count)
61
+ default 3
62
+ comment "Define how many times the monitor process will check for other servers",
63
+ "at start up. Limited to at least once and at most 10 times. Probably is not need",
64
+ "to check more than 3 times unless you set a very short scan timeout."
65
+ in_range(count, 1, 10)
66
+ end
67
+
68
+ def configure_loop_time(delay)
69
+ default 30
70
+ comment "Define the delay between successive checks carried out by the monitor at start up.",
71
+ "Setting it to 0 will cause the checks to be completed without delay. The upper limit is",
72
+ "an hour for no particular reason. Default should work for most cases. Could be quicker on smaller",
73
+ "nets with fewer machines to check each time."
74
+ in_range(delay, 0, 360)
75
+ end
76
+
60
77
  def configure_secret(scrt)
61
78
  comment "A secret key available to all Jerbil Servers and used to authenticate the initial registration.",
62
79
  "If security is an issue, ensure that this config file is readable only be trusted users"