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.
@@ -1,2 +0,0 @@
1
- # a simple client config file for jerbil
2
- environment :prod
@@ -1,76 +0,0 @@
1
- #
2
- #
3
- # = Title
4
- #
5
- # == SubTitle
6
- #
7
- # Author:: Robert Sharp
8
- # Copyright:: Copyright (c) 2011 Robert Sharp
9
- # License:: Open Software Licence v3.0
10
- #
11
- # This software is licensed for use under the Open Software Licence v. 3.0
12
- # The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
13
- # and in the file copyright.txt. Under the terms of this licence, all derivative works
14
- # must themselves be licensed under the Open Software Licence v. 3.0
15
- #
16
- #
17
- #
18
-
19
- # define subcommands relating to Jerbil Servers
20
- class Server < Thor
21
-
22
- default_task :local
23
- class_option :config, :aliases=>'-c', :desc=>'use the given config file', :default=>'/etc/jermine/jerbil-client.rb'
24
- class_option :verify, :aliases=>'-v', :desc=>'check the server is running'
25
-
26
- desc "local", "display information about the local jerbil server"
27
- def local
28
- config = Jerbil.get_config(options[:config])
29
- local = Jerbil::Servers.get_local_server(config[:environment])
30
- puts "Checking for local Jerbil server running in env: #{config[:environment]}"
31
- begin
32
- jerbs = local.connect
33
- started = jerbs.started
34
- puts " Jerbil server found, version: #{jerbs.version}".green
35
- puts " Server has been up since #{started.strftime('%d %b %Y at %H:%M')}"
36
- puts " and has had #{jerbs.registrations.to_s} registrations"
37
- rescue Exception => err
38
- puts " Server did not respond: #{err.message}".red.bold
39
- end
40
-
41
- end
42
-
43
- desc "list", "list information about the network's Jerbil servers"
44
- def list
45
- config = Jerbil.get_config(options[:config])
46
- local = Jerbil::Servers.get_local_server(config[:environment])
47
- puts "Checking for Jerbil servers running in env: #{config[:environment]}"
48
- begin
49
- jerbs = local.connect
50
- remotes = jerbs.remote_servers
51
- remotes.each do |remote|
52
- if options[:verify] then
53
- begin
54
- remote.connect.verify
55
- puts " #{remote.ident}".green
56
- rescue
57
- puts " #{remote.ident}".red
58
- end
59
- else
60
- puts " #{remote.ident}".cyan
61
- end
62
- end
63
- rescue Exception => err
64
- puts " Server did not respond: #{err.message}".red.bold
65
- end
66
-
67
- end
68
-
69
- desc "secret", "generate a secret key for a new installation"
70
- def secret
71
- key = Digest::SHA1.hexdigest(Time.now.to_s + rand(12341234).to_s)
72
- puts 'secret "' + key + '"'
73
- end
74
-
75
-
76
- end
@@ -1,74 +0,0 @@
1
- #
2
- #
3
- # = Title
4
- #
5
- # == SubTitle
6
- #
7
- # Author:: Robert Sharp
8
- # Copyright:: Copyright (c) 2011 Robert Sharp
9
- # License:: Open Software Licence v3.0
10
- #
11
- # This software is licensed for use under the Open Software Licence v. 3.0
12
- # The terms of this licence can be found at http://www.opensource.org/licenses/osl-3.0.php
13
- # and in the file copyright.txt. Under the terms of this licence, all derivative works
14
- # must themselves be licensed under the Open Software Licence v. 3.0
15
- #
16
- #
17
- #
18
-
19
- class Service < Thor
20
-
21
- default_task :list
22
- class_option :verbose, :default=>false, :aliases=>'-V', :desc=>'print more information'
23
- class_option :verify, :aliases=>'-v', :desc=>'check the service is running'
24
- class_option :config, :aliases=>'-c', :desc=>'use the given config file', :default=>'/etc/jermine/jerbil-client.rb'
25
-
26
- desc "list", "List services"
27
- def list
28
- config = Jerbil.get_config(options[:config])
29
- local = Jerbil::Servers.get_local_server(config[:environment])
30
- services = []
31
- begin
32
- jerbs = local.connect
33
- services = jerbs.get_all(true) # ignore this access
34
- rescue
35
- puts "Failed to connect to the local Jerbil server".red.bold
36
- return
37
- end
38
- puts "There are #{services.length} services registered with Jerbil:"
39
- services.each do |s|
40
- puts " #{s.name}[:#{s.env}]@#{s.host}:#{s.port}".cyan
41
- puts " started at: #{s.registered_at.strftime('%d/%m/%y %H:%M')}" if options[:verbose]
42
- puts " accessed #{s.access_count.to_s} times, last time at: #{s.accessed_at.strftime('%d/%m/%y %H:%M')}" if options[:verbose]
43
- if options[:verify] then
44
- if jerbs.service_missing?(s) then
45
- puts " #{s.ident} has failed and should be removed".red
46
- else
47
- puts " #{s.ident} responded".green
48
- end
49
- end
50
- end
51
- end
52
-
53
- desc "verify", "Verify that services are running"
54
- def verify
55
- config = Jerbil.get_config(options[:config])
56
- local = Jerbil::Servers.get_local_server(options[:environment])
57
- services = []
58
- begin
59
- jerbs = local.connect
60
- services = jerbs.get_all(true) # ignore this access
61
- rescue
62
- puts "Failed to connect to the local Jerbil server".red.bold
63
- end
64
- puts "Checking #{services.length} services registered with Jerbil:"
65
- services.each do |s|
66
- if jerbs.service_missing?(s) then
67
- puts " #{s.ident} has failed and should be removed".red
68
- else
69
- puts " #{s.ident} responded".green
70
- end
71
- end
72
- end
73
-
74
- end