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.
Files changed (86) hide show
  1. data/Bugs.rdoc +66 -0
  2. data/Gemfile +12 -0
  3. data/History.txt +359 -0
  4. data/Intro.txt +5 -0
  5. data/LICENCE.rdoc +159 -0
  6. data/README.md +335 -0
  7. data/README_SERVICES.md +410 -0
  8. data/README_TESTING.md +47 -0
  9. data/bin/jerbil +62 -0
  10. data/bin/jerbil-install +56 -0
  11. data/etc/conf.d/jerbild +15 -0
  12. data/etc/conf.d/jserviced +39 -0
  13. data/etc/init.d/jerbild +55 -0
  14. data/etc/init.d/jserviced +59 -0
  15. data/etc/jerbil/jerbil-client.rb +2 -0
  16. data/etc/jerbil/jerbil.rb +83 -0
  17. data/lib/jerbil.rb +636 -0
  18. data/lib/jerbil/config.md +49 -0
  19. data/lib/jerbil/config.rb +67 -0
  20. data/lib/jerbil/errors.rb +74 -0
  21. data/lib/jerbil/jerbil_service/base.rb +191 -0
  22. data/lib/jerbil/jerbil_service/client.rb +325 -0
  23. data/lib/jerbil/jerbil_service/config.md +119 -0
  24. data/lib/jerbil/jerbil_service/config.rb +72 -0
  25. data/lib/jerbil/jerbil_service/sclient.rb +343 -0
  26. data/lib/jerbil/jerbil_service/support.rb +58 -0
  27. data/lib/jerbil/jerbil_service/utils.rb +35 -0
  28. data/lib/jerbil/servers.rb +230 -0
  29. data/lib/jerbil/service.rb +216 -0
  30. data/lib/jerbil/support.rb +160 -0
  31. data/lib/jerbil/thor/server.rb +76 -0
  32. data/lib/jerbil/thor/service.rb +74 -0
  33. data/lib/jerbil/version.rb +13 -0
  34. data/sbin/jerbil-status +120 -0
  35. data/sbin/jerbil-stop +139 -0
  36. data/sbin/jerbild +186 -0
  37. data/sbin/jservice-status +107 -0
  38. data/sbin/jservice-stop +94 -0
  39. data/sbin/jserviced +111 -0
  40. data/spec/jerbil_2_jerbil_spec.rb +87 -0
  41. data/spec/jerbil_client1_spec.rb +80 -0
  42. data/spec/jerbil_client_spec.rb +114 -0
  43. data/spec/jerbil_client_stop_spec.rb +24 -0
  44. data/spec/jerbil_daemonised/jerbil_local_spec.rb +81 -0
  45. data/spec/jerbil_daemonised/jerbil_remote_spec.rb +116 -0
  46. data/spec/jerbil_load.rb +48 -0
  47. data/spec/jerbil_local_spec.rb +91 -0
  48. data/spec/jerbil_missing_spec.rb +98 -0
  49. data/spec/jerbil_remote_spec.rb +117 -0
  50. data/spec/jerbil_remote_spec_bup.rb +168 -0
  51. data/spec/jerbil_service_error_spec.rb +56 -0
  52. data/spec/jerbil_service_spec.rb +41 -0
  53. data/spec/jerbil_support_spec.rb +69 -0
  54. data/spec/jservice_utils_spec.rb +38 -0
  55. data/spec/server_spec.rb +69 -0
  56. data/spec/server_update_spec.rb +28 -0
  57. data/spec/service_spec.rb +72 -0
  58. data/spec/spec_helper.rb +12 -0
  59. data/spec/test_env_spec.rb +53 -0
  60. data/test/bad_test_service.rb +31 -0
  61. data/test/conf.d/jerbil +36 -0
  62. data/test/conf.d/jerbil.conf +39 -0
  63. data/test/conf.d/jerbil.rb +55 -0
  64. data/test/conf.d/jerbil_local.rb +33 -0
  65. data/test/conf.d/jerbil_no_local.conf +39 -0
  66. data/test/conf.d/jerbil_old.rb +47 -0
  67. data/test/conf.d/jerbil_test.rb +35 -0
  68. data/test/conf.d/malformed +1 -0
  69. data/test/conf.d/missing_services +39 -0
  70. data/test/conf.d/ruby_test.rb +8 -0
  71. data/test/init.d/jerbild +14 -0
  72. data/test/jerbil.rb +51 -0
  73. data/test/jerbil_config.rb +8 -0
  74. data/test/jstop.rb +36 -0
  75. data/test/key.asc +1 -0
  76. data/test/lib/ruby_test.rb +37 -0
  77. data/test/lib/ruby_test/config.rb +56 -0
  78. data/test/lib/ruby_test/version.rb +13 -0
  79. data/test/pids/jerbil-prod.asc +1 -0
  80. data/test/pids/jerbil-prod.pid +1 -0
  81. data/test/pids/jerbil.pid +1 -0
  82. data/test/private_key_file.asc +3 -0
  83. data/test/service-stop.rb +86 -0
  84. data/test/service_mock.rb +94 -0
  85. data/test/test_service_client.rb +25 -0
  86. metadata +265 -0
@@ -0,0 +1,31 @@
1
+ #
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
+ require 'jerbil/jerbil_service/base'
15
+
16
+ # Test Service for Jerbil
17
+
18
+ class BadTestService < JerbilService::Base
19
+
20
+ def initialize(pkey, options)
21
+ super(:rubynonsense, :test, pkey, options)
22
+ end
23
+
24
+ def action
25
+ @logger.debug("Someone called the action method!")
26
+ return "Hello"
27
+ end
28
+
29
+ end
30
+
31
+
@@ -0,0 +1,36 @@
1
+
2
+ require 'socket'
3
+ require 'jerbil/server'
4
+
5
+ # Array of Jerbil::Server, one for each server in the system
6
+ hostname = Socket.gethostname
7
+ my_servers = Array.new
8
+ my_servers << Jerbil::Server.new(hostname, 'ABCDE')
9
+ my_servers << Jerbil::Server.new(hostname, 'DEVELOPMENT')
10
+ my_servers << Jerbil::Server.new('antonia', 'JKLMNOP')
11
+
12
+ servers my_servers
13
+
14
+
15
+ # Controls the amount of logging done by Jellog
16
+ #
17
+ # * :system - standard message, plus log to syslog
18
+ # * :verbose - more generous logging to help resolve problems
19
+ # * :debug - usually used only for resolving problems during development
20
+ #
21
+ log_level :debug
22
+
23
+ # Location for Jellog (logging utility) to save log files
24
+ log_dir "/home/robert/dev/projects/jerbil/log"
25
+
26
+ # Size of a log file (in MB) before switching to the next log
27
+ #log_length 1
28
+
29
+ # Number of log files to retain at any moment
30
+ #log_rotation 2
31
+
32
+ # private key file used to authenticate privileged users
33
+ key_file "/home/robert/dev/projects/jerbil/test/private_key_file.asc"
34
+
35
+ # somewhere to store the pid
36
+ pid_dir "/home/robert/dev/projects/jerbil/test/pids"
@@ -0,0 +1,39 @@
1
+ project_root = '/home/robert/dev/projects/jerbil'
2
+ env = :dev
3
+ environment env
4
+
5
+ # directory used to store the daemons pid to assist in stopping reluctant servers
6
+ pid_dir "#{project_root}/test/pids"
7
+
8
+ # Number of log files to retain at any moment
9
+ #log_rotation 2
10
+
11
+ # Location for Jellog (logging utility) to save log files
12
+ log_dir "#{project_root}/log"
13
+
14
+ # Size of a log file (in MB) before switching to the next log
15
+ #log_length 1
16
+
17
+ # Controls the amount of logging done by Jellog
18
+ #
19
+ # * :system - standard message, plus log to syslog
20
+ # * :verbose - more generous logging to help resolve problems
21
+ # * :debug - usually used only for resolving problems during development
22
+ #
23
+ log_level :debug
24
+
25
+ # Array of Jerbil::Server, one for each server in the system
26
+ require 'jerbil/server'
27
+
28
+ my_servers = Array.new
29
+ my_servers << Jerbil::ServerRecord.new("lucius.osburn-sharp.ath.cx","Amz09+C8GqQ+StC9wbPEKE2dm5WbOxLVXM+McvxnJ7QM17qcnYshzF0zFOGK", env)
30
+ my_servers << Jerbil::ServerRecord.new("germanicus.osburn-sharp.ath.cx","2lR3hsR8mrpcQ8GfN7Tpukwt15/u1Npctp1owQt89jLEZEbpOZWmK/C1aQW4", env)
31
+ my_servers << Jerbil::ServerRecord.new("octavia.osburn-sharp.ath.cx","WJbgpOfYOBjlSjcPGyheouPBIJNwhJrKmIqUFly5oLBaHJ8NtI1nhTDrk5p3", env)
32
+ my_servers << Jerbil::ServerRecord.new("antonia.osburn-sharp.ath.cx","gpbYk9BEcmyO4xZfZuwu1/Nkd6Dnxjo+INRtrkBmGEQUq3KYi7NfBVW4pfGV", env)
33
+ my_servers << Jerbil::ServerRecord.new("valeria.osburn-sharp.ath.cx","V05+VKO0rxNm0qz0BqfJKaAyxZOO1YsyXnYknE3PmzKJg5tbUFsz39YA12LJ", env)
34
+
35
+ servers my_servers
36
+
37
+ # private key file used to authenticate privileged users
38
+ key_dir "#{project_root}/test/pids"
39
+
@@ -0,0 +1,55 @@
1
+ project_root = File.expand_path('../..', File.dirname(__FILE__))
2
+ # directory used to store the daemons pid to assist in stopping reluctant servers
3
+ pid_dir File.join(project_root, 'tmp')
4
+
5
+ # Set the default environment for service commands etc.
6
+ #
7
+ # Can be one of :prod, :test, :dev
8
+ environment :dev
9
+
10
+ # Number of log files to retain at any moment
11
+ #log_rotation 2
12
+
13
+ # Location for Jellog (logging utility) to save log files
14
+ log_dir File.join(project_root, 'log')
15
+
16
+ # Size of a log file (in MB) before switching to the next log
17
+ #log_length 1
18
+
19
+ # Controls the amount of logging done by Jellog
20
+ #
21
+ # * :system - standard message, plus log to syslog
22
+ # * :verbose - more generous logging to help resolve problems
23
+ # * :debug - usually used only for resolving problems during development
24
+ #
25
+ log_level :debug
26
+
27
+
28
+ # private key file used to authenticate privileged users
29
+ key_dir File.join(project_root, 'tmp')
30
+
31
+ # Provide the name of the user under which this process should run
32
+ # being a valid user name for the current system. If not provided, the
33
+ # application will not attempt to change user id
34
+ #user 'jermine'
35
+
36
+
37
+ # Boolean - set to false to prevent service from executing exit! on stop
38
+ #exit_on_stop true
39
+
40
+ # Provide a timeout when searching for jerbil servers on the net. Depending on the size of the net mask
41
+ # this timeout may make the search long. The default should work in most cases
42
+ scan_timeout 0.1
43
+
44
+ # A valid IPv4 address for the LAN on which the servers will operate.
45
+ # Note that the broker uses this address to search for all servers.
46
+ # Therefore a large range will take a long time to search. Set the net_mask to limit this.
47
+ net_address "192.168.0.1"
48
+
49
+ # A secret key available to all Jerbil Servers and used to authenticate the inital registration.
50
+ # If security is an issue, ensure that this config file is readable only be trusted users
51
+ secret "5830a7bf3b6c832ffa8344f1e3e13aaff1795742"
52
+
53
+ # A valid netmask for the hosts to search using the above net address. This should be
54
+ # between 24 (a class C network) and 30, beyound which its not much of a network. If you only have a few
55
+ net_mask 26
@@ -0,0 +1,33 @@
1
+ project_root = '/home/robert/dev/projects/jerbil'
2
+ env = :dev
3
+ environment env
4
+
5
+ # directory used to store the daemons pid to assist in stopping reluctant servers
6
+ pid_dir "#{project_root}/test/pids"
7
+
8
+ # Number of log files to retain at any moment
9
+ #log_rotation 2
10
+
11
+ # Location for Jellog (logging utility) to save log files
12
+ log_dir "#{project_root}/log"
13
+
14
+ # Size of a log file (in MB) before switching to the next log
15
+ #log_length 1
16
+
17
+ # Controls the amount of logging done by Jellog
18
+ #
19
+ # * :system - standard message, plus log to syslog
20
+ # * :verbose - more generous logging to help resolve problems
21
+ # * :debug - usually used only for resolving problems during development
22
+ #
23
+ log_level :debug
24
+
25
+ # private key file used to authenticate privileged users
26
+ key_dir "#{project_root}/test/pids"
27
+
28
+
29
+ # netmask
30
+ net_address '192.168.0.1'
31
+ net_mask 26
32
+ scan_timeout 0.1
33
+ secret '123456789=[]'
@@ -0,0 +1,39 @@
1
+ project_root = '/home/robert/dev/projects/jerbil'
2
+ env = :dev
3
+ environment env
4
+
5
+ # directory used to store the daemons pid to assist in stopping reluctant servers
6
+ pid_dir "#{project_root}/test/pids"
7
+
8
+ # Number of log files to retain at any moment
9
+ #log_rotation 2
10
+
11
+ # Location for Jellog (logging utility) to save log files
12
+ log_dir "#{project_root}/log"
13
+
14
+ # Size of a log file (in MB) before switching to the next log
15
+ #log_length 1
16
+
17
+ # Controls the amount of logging done by Jellog
18
+ #
19
+ # * :system - standard message, plus log to syslog
20
+ # * :verbose - more generous logging to help resolve problems
21
+ # * :debug - usually used only for resolving problems during development
22
+ #
23
+ log_level :debug
24
+
25
+ # Array of Jerbil::Server, one for each server in the system
26
+ require 'jerbil/server'
27
+
28
+ my_servers = Array.new
29
+ #my_servers << Jerbil::ServerRecord.new("lucius.osburn-sharp.ath.cx","Amz09+C8GqQ+StC9wbPEKE2dm5WbOxLVXM+McvxnJ7QM17qcnYshzF0zFOGK", env)
30
+ my_servers << Jerbil::ServerRecord.new("germanicus.osburn-sharp.ath.cx","2lR3hsR8mrpcQ8GfN7Tpukwt15/u1Npctp1owQt89jLEZEbpOZWmK/C1aQW4", env)
31
+ my_servers << Jerbil::ServerRecord.new("octavia.osburn-sharp.ath.cx","WJbgpOfYOBjlSjcPGyheouPBIJNwhJrKmIqUFly5oLBaHJ8NtI1nhTDrk5p3", env)
32
+ my_servers << Jerbil::ServerRecord.new("antonia.osburn-sharp.ath.cx","gpbYk9BEcmyO4xZfZuwu1/Nkd6Dnxjo+INRtrkBmGEQUq3KYi7NfBVW4pfGV", env)
33
+ my_servers << Jerbil::ServerRecord.new("valeria.osburn-sharp.ath.cx","V05+VKO0rxNm0qz0BqfJKaAyxZOO1YsyXnYknE3PmzKJg5tbUFsz39YA12LJ", env)
34
+
35
+ servers my_servers
36
+
37
+ # private key file used to authenticate privileged users
38
+ key_dir "#{project_root}/test/pids"
39
+
@@ -0,0 +1,47 @@
1
+ # directory used to store the daemons pid to assist in stopping reluctant servers
2
+ pid_dir "/var/run/jerbil"
3
+
4
+ # Set the default environment for service commands etc.
5
+ #
6
+ # Can be one of :prod, :test, :dev
7
+ environment :prod
8
+
9
+ # Number of log files to retain at any moment
10
+ #log_rotation 2
11
+
12
+ # Location for Jellog (logging utility) to save log files
13
+ log_dir "/var/log/jerbil"
14
+
15
+ # Size of a log file (in MB) before switching to the next log
16
+ #log_length 1
17
+
18
+ # Controls the amount of logging done by Jellog
19
+ #
20
+ # * :system - standard message, plus log to syslog
21
+ # * :verbose - more generous logging to help resolve problems
22
+ # * :debug - usually used only for resolving problems during development
23
+ #
24
+ log_level :debug
25
+
26
+
27
+ # private key file used to authenticate privileged users
28
+ key_dir "/var/run/jerbil"
29
+
30
+ # Provide a timeout when searching for jerbil servers on the net. Depending on the size of the net mask
31
+ # this timeout may make the search long. The default should work in most cases
32
+ scan_timeout 0.1
33
+
34
+ # A valid IPv4 address for the LAN on which the servers will operate.
35
+ # Note that the broker uses this address to search for all servers.
36
+ # Therefore a large range will take a long time to search. Set the net_mask to limit this.
37
+ net_address "192.168.0.1"
38
+
39
+ # A secret key available to all Jerbil Servers and used to authenticate the inital registration.
40
+ # If security is an issue, ensure that this config file is readable only be trusted users
41
+ #
42
+ # Generate a new secret with something like: openssl genrsa -des3 and paste a line into here
43
+ secret "hK78l/z1mIDBOs+/Qx2q7k5beExChmdc3tpw81qTBNLmcQknRrY93oHzIAd3DNo2"
44
+
45
+ # A valid netmask for the hosts to search using the above net address. This should be
46
+ # between 24 (a class C network) and 30, beyound which its not much of a network. If you only have a few
47
+ net_mask 26
@@ -0,0 +1,35 @@
1
+ project_root = '/home/robert/dev/projects/jerbil'
2
+ env = :test
3
+ environment env
4
+
5
+ # directory used to store the daemons pid to assist in stopping reluctant servers
6
+ pid_dir "#{project_root}/test/pids"
7
+
8
+ # Number of log files to retain at any moment
9
+ #log_rotation 2
10
+
11
+ # Location for Jellog (logging utility) to save log files
12
+ log_dir "#{project_root}/log"
13
+
14
+ # Size of a log file (in MB) before switching to the next log
15
+ #log_length 1
16
+
17
+ # Controls the amount of logging done by Jellog
18
+ #
19
+ # * :system - standard message, plus log to syslog
20
+ # * :verbose - more generous logging to help resolve problems
21
+ # * :debug - usually used only for resolving problems during development
22
+ #
23
+ log_level :debug
24
+
25
+ # private key file used to authenticate privileged users
26
+ key_dir "#{project_root}/test/pids"
27
+
28
+ #user 'robert'
29
+
30
+
31
+ # netmask
32
+ net_address '192.168.0.1'
33
+ net_mask 26
34
+ scan_timeout 0.1
35
+ secret '123456789=[]'
@@ -0,0 +1 @@
1
+ what_is_this "I do not know"
@@ -0,0 +1,39 @@
1
+ phome = '/home/robert/dev/projects/'
2
+ env = :dev
3
+ environment env
4
+
5
+ # directory used to store the daemons pid to assist in stopping reluctant servers
6
+ pid_dir phome + "jerbil/test/pids"
7
+
8
+ # Number of log files to retain at any moment
9
+ #log_rotation 2
10
+
11
+ # Location for Jellog (logging utility) to save log files
12
+ log_dir phome + "jerbil/log"
13
+
14
+ # Size of a log file (in MB) before switching to the next log
15
+ #log_length 1
16
+
17
+ # Controls the amount of logging done by Jellog
18
+ #
19
+ # * :system - standard message, plus log to syslog
20
+ # * :verbose - more generous logging to help resolve problems
21
+ # * :debug - usually used only for resolving problems during development
22
+ #
23
+ log_level :debug
24
+
25
+ # Array of Jerbil::Server, one for each server in the system
26
+ require 'jerbil/server'
27
+
28
+ my_servers = Array.new
29
+ my_servers << Jerbil::ServerRecord.new("lucius.osburn-sharp.ath.cx","Amz09+C8GqQ+StC9wbPEKE2dm5WbOxLVXM+McvxnJ7QM17qcnYshzF0zFOGK", env)
30
+ my_servers << Jerbil::ServerRecord.new("germanicus.osburn-sharp.ath.cx","2lR3hsR8mrpcQ8GfN7Tpukwt15/u1Npctp1owQt89jLEZEbpOZWmK/C1aQW4", env)
31
+ my_servers << Jerbil::ServerRecord.new("octavia.osburn-sharp.ath.cx","WJbgpOfYOBjlSjcPGyheouPBIJNwhJrKmIqUFly5oLBaHJ8NtI1nhTDrk5p3", env)
32
+ my_servers << Jerbil::ServerRecord.new("antonia.osburn-sharp.ath.cx","gpbYk9BEcmyO4xZfZuwu1/Nkd6Dnxjo+INRtrkBmGEQUq3KYi7NfBVW4pfGV", env)
33
+ my_servers << Jerbil::ServerRecord.new("valeria.osburn-sharp.ath.cx","V05+VKO0rxNm0qz0BqfJKaAyxZOO1YsyXnYknE3PmzKJg5tbUFsz39YA12LJ", env)
34
+
35
+ servers my_servers
36
+
37
+ # private key file used to authenticate privileged users
38
+ key_dir phome + "jerbil/test/"
39
+
@@ -0,0 +1,8 @@
1
+ environment :dev
2
+ log_dir "/home/robert/dev/projects/jerbil/log"
3
+ log_level :debug
4
+ key_dir "/home/robert/dev/projects/jerbil/test/pids"
5
+ pid_dir "/home/robert/dev/projects/jerbil/test/pids"
6
+ jerbil_config "/home/robert/dev/projects/jerbil/test/conf.d/jerbil.rb"
7
+ #user 'robert'
8
+ jerbil_env :test
@@ -0,0 +1,14 @@
1
+ #!/bin/bash
2
+
3
+ # create the options for starting the daemon from the settings in the
4
+ # /etc/conf.d/jerbild file
5
+ myopts=""
6
+ [ -n "${NO_DAEMON}" ] && myopts="${myopts} -n"
7
+ [ -n "${CONF_FILE}" ] && myopts="${myopts} -c ${CONF_FILE}"
8
+ [ "${VERBOSE}" == "true" ] && [ "${QUIET}" != "true" ] && myopts="${myopts} -V"
9
+ [ -n "${NO_SYSLOG}" ] && myopts="${myopts} -S"
10
+
11
+
12
+ ${PROJECT_ROOT}/sbin/jerbild ${myopts}
13
+
14
+
@@ -0,0 +1,51 @@
1
+ #
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
+ # Test version of Jerbil Server
17
+ #
18
+
19
+ require 'jerbil'
20
+ require 'jerbil/server'
21
+ require 'jerbil/config'
22
+ require 'jellog'
23
+ require 'jeckyl'
24
+ require 'socket'
25
+ require 'drb'
26
+
27
+
28
+ hostname = Socket.gethostname
29
+ my_self = Jerbil::ServerRecord.new(hostname, 'ABCDE')
30
+ #another = Jerbil::Server.new('antonia', 'JKLMNOP')
31
+ #servers = [my_self, another]
32
+
33
+ config_file = File.expand_path(File.dirname(__FILE__) + '/../test/conf.d/jerbil')
34
+
35
+ options = Jerbil::Config.new(config_file)
36
+ puts options.inspect
37
+
38
+ servers = options.delete(:servers)
39
+
40
+ # prevent the server from generating syslogs
41
+ Jellog.disable_syslog
42
+
43
+ $SAFE = 1 # using DRb, so prevent anything nasty
44
+
45
+ jerbild = Jerbil.new(my_self, servers, options)
46
+
47
+ DRb.start_service(my_self.drb_address, jerbild)
48
+
49
+ puts "Started Jerbil Test Server in foreground. Please wait"
50
+
51
+ DRb.thread.join