bluepill 0.0.57 → 0.0.58
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.
- data/lib/bluepill/process.rb +0 -4
- data/lib/bluepill/version.rb +1 -1
- data/local-bluepill +129 -0
- metadata +24 -23
data/lib/bluepill/process.rb
CHANGED
data/lib/bluepill/version.rb
CHANGED
data/local-bluepill
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
$LOAD_PATH.unshift(File.expand_path('lib', File.dirname(__FILE__)))
|
6
|
+
|
7
|
+
require 'optparse'
|
8
|
+
require 'bluepill'
|
9
|
+
|
10
|
+
begin
|
11
|
+
require 'rbconfig'
|
12
|
+
rescue LoadError
|
13
|
+
end
|
14
|
+
|
15
|
+
RbConfig = Config unless Object.const_defined?(:RbConfig)
|
16
|
+
|
17
|
+
# Default options
|
18
|
+
options = {
|
19
|
+
:log_file => "/var/log/bluepill.log",
|
20
|
+
:base_dir => "/var/run/bluepill",
|
21
|
+
:privileged => true,
|
22
|
+
:timeout => 10,
|
23
|
+
:attempts => 1
|
24
|
+
}
|
25
|
+
|
26
|
+
OptionParser.new do |opts|
|
27
|
+
opts.banner = "Usage: bluepill [app] cmd [options]"
|
28
|
+
opts.on('-l', "--logfile LOGFILE", "Path to logfile, defaults to #{options[:log_file]}") do |file|
|
29
|
+
options[:log_file] = file
|
30
|
+
end
|
31
|
+
|
32
|
+
opts.on('-c', "--base-dir DIR", "Directory to store bluepill socket and pid files, defaults to #{options[:base_dir]}") do |base_dir|
|
33
|
+
options[:base_dir] = base_dir
|
34
|
+
end
|
35
|
+
|
36
|
+
opts.on("-v", "--version") do
|
37
|
+
puts "bluepill, version #{Bluepill::VERSION}"
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
|
41
|
+
opts.on("--[no-]privileged", "Allow/disallow to run #{$0} as non-privileged process. disallowed by default") do |v|
|
42
|
+
options[:privileged] = v
|
43
|
+
end
|
44
|
+
|
45
|
+
opts.on('-t', '--timeout Seconds', Integer, "Timeout for commands sent to the daemon, in seconds. Defaults to 10.") do |timeout|
|
46
|
+
options[:timeout] = timeout
|
47
|
+
end
|
48
|
+
|
49
|
+
opts.on('--attempts Count', Integer, "Attempts for commands sent to the daemon, in seconds. Defaults to 1.") do |attempts|
|
50
|
+
options[:attempts] = attempts
|
51
|
+
end
|
52
|
+
|
53
|
+
help = proc do
|
54
|
+
puts opts
|
55
|
+
puts
|
56
|
+
puts "Commands:"
|
57
|
+
puts " load CONFIG_FILE\t\tLoads new instance of bluepill using the specified config file"
|
58
|
+
puts " status\t\t\tLists the status of the proceses for the specified app"
|
59
|
+
puts " start [TARGET]\t\tIssues the start command for the target process or group, defaults to all processes"
|
60
|
+
puts " stop [TARGET]\t\tIssues the stop command for the target process or group, defaults to all processes"
|
61
|
+
puts " restart [TARGET]\t\tIssues the restart command for the target process or group, defaults to all processes"
|
62
|
+
puts " unmonitor [TARGET]\t\tStop monitoring target process or group, defaults to all processes"
|
63
|
+
puts " log [TARGET]\t\tShow the log for the specified process or group, defaults to all for app"
|
64
|
+
puts " quit\t\t\tStop bluepill"
|
65
|
+
puts
|
66
|
+
puts "See http://github.com/arya/bluepill for README"
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
|
70
|
+
opts.on_tail('-h','--help', 'Show this message', &help)
|
71
|
+
help.call if ARGV.empty?
|
72
|
+
end.parse!
|
73
|
+
|
74
|
+
# Check for root
|
75
|
+
if options[:privileged] && ::Process.euid != 0
|
76
|
+
$stderr.puts "You must run bluepill as root or use --no-privileged option."
|
77
|
+
exit(3)
|
78
|
+
end
|
79
|
+
|
80
|
+
APPLICATION_COMMANDS = %w(status start stop restart unmonitor quit log)
|
81
|
+
|
82
|
+
controller = Bluepill::Controller.new(options.slice(:base_dir, :log_file))
|
83
|
+
|
84
|
+
if controller.running_applications.include?(File.basename($0)) && File.symlink?($0)
|
85
|
+
# bluepill was called as a symlink with the name of the target application
|
86
|
+
options[:application] = File.basename($0)
|
87
|
+
elsif controller.running_applications.include?(ARGV.first)
|
88
|
+
# the first arg is the application name
|
89
|
+
options[:application] = ARGV.shift
|
90
|
+
elsif APPLICATION_COMMANDS.include?(ARGV.first)
|
91
|
+
if controller.running_applications.length == 1
|
92
|
+
# there is only one, let's just use that
|
93
|
+
options[:application] = controller.running_applications.first
|
94
|
+
elsif controller.running_applications.length > 1
|
95
|
+
# There is more than one, tell them the list and exit
|
96
|
+
$stderr.puts "You must specify an application name to run that command. Here's the list of running applications:"
|
97
|
+
controller.running_applications.each_with_index do |app, index|
|
98
|
+
$stderr.puts " #{index + 1}. #{app}"
|
99
|
+
end
|
100
|
+
$stderr.puts "Usage: bluepill [app] cmd [options]"
|
101
|
+
exit(1)
|
102
|
+
else
|
103
|
+
# There are none running AND they aren't trying to start one
|
104
|
+
$stderr.puts "Error: There are no running bluepill daemons.\nTo start a bluepill daemon, use: bluepill load <config file>"
|
105
|
+
exit(2)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
options[:command] = ARGV.shift
|
110
|
+
|
111
|
+
if options[:command] == "load"
|
112
|
+
file = ARGV.shift
|
113
|
+
if File.exists?(file)
|
114
|
+
# Restart the ruby interpreter for the config file so that anything loaded here
|
115
|
+
# does not stay in memory for the daemon
|
116
|
+
ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
117
|
+
load_path = File.expand_path("#{File.dirname(__FILE__)}/../lib")
|
118
|
+
file_path = File.expand_path(file)
|
119
|
+
|
120
|
+
exec(ruby, "-I#{load_path}", '-rbluepill', file_path)
|
121
|
+
|
122
|
+
else
|
123
|
+
$stderr.puts "Can't find file: #{file}"
|
124
|
+
end
|
125
|
+
else
|
126
|
+
target = ARGV.shift
|
127
|
+
controller.handle_command(options[:application], options[:command], target)
|
128
|
+
end
|
129
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bluepill
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.58
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ date: 2012-02-20 00:00:00.000000000 Z
|
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: daemons
|
18
|
-
requirement: &
|
18
|
+
requirement: &2152005780 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|
20
20
|
requirements:
|
21
21
|
- - ~>
|
@@ -26,10 +26,10 @@ dependencies:
|
|
26
26
|
version: 1.1.6
|
27
27
|
type: :runtime
|
28
28
|
prerelease: false
|
29
|
-
version_requirements: *
|
29
|
+
version_requirements: *2152005780
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: state_machine
|
32
|
-
requirement: &
|
32
|
+
requirement: &2152005040 !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
35
|
- - ~>
|
@@ -37,10 +37,10 @@ dependencies:
|
|
37
37
|
version: 1.1.0
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
|
-
version_requirements: *
|
40
|
+
version_requirements: *2152005040
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
|
-
requirement: &
|
43
|
+
requirement: &2152004580 !ruby/object:Gem::Requirement
|
44
44
|
none: false
|
45
45
|
requirements:
|
46
46
|
- - ! '>='
|
@@ -48,10 +48,10 @@ dependencies:
|
|
48
48
|
version: 3.0.0
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
|
-
version_requirements: *
|
51
|
+
version_requirements: *2152004580
|
52
52
|
- !ruby/object:Gem::Dependency
|
53
53
|
name: i18n
|
54
|
-
requirement: &
|
54
|
+
requirement: &2152004120 !ruby/object:Gem::Requirement
|
55
55
|
none: false
|
56
56
|
requirements:
|
57
57
|
- - ! '>='
|
@@ -59,10 +59,10 @@ dependencies:
|
|
59
59
|
version: 0.5.0
|
60
60
|
type: :runtime
|
61
61
|
prerelease: false
|
62
|
-
version_requirements: *
|
62
|
+
version_requirements: *2152004120
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
64
|
name: bundler
|
65
|
-
requirement: &
|
65
|
+
requirement: &2152003660 !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|
68
68
|
- - ! '>='
|
@@ -70,10 +70,10 @@ dependencies:
|
|
70
70
|
version: 1.0.10
|
71
71
|
type: :development
|
72
72
|
prerelease: false
|
73
|
-
version_requirements: *
|
73
|
+
version_requirements: *2152003660
|
74
74
|
- !ruby/object:Gem::Dependency
|
75
75
|
name: rake
|
76
|
-
requirement: &
|
76
|
+
requirement: &2152003200 !ruby/object:Gem::Requirement
|
77
77
|
none: false
|
78
78
|
requirements:
|
79
79
|
- - ! '!='
|
@@ -81,10 +81,10 @@ dependencies:
|
|
81
81
|
version: 0.9.0
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
|
-
version_requirements: *
|
84
|
+
version_requirements: *2152003200
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: rspec-core
|
87
|
-
requirement: &
|
87
|
+
requirement: &2152002740 !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|
90
90
|
- - ~>
|
@@ -92,10 +92,10 @@ dependencies:
|
|
92
92
|
version: '2.0'
|
93
93
|
type: :development
|
94
94
|
prerelease: false
|
95
|
-
version_requirements: *
|
95
|
+
version_requirements: *2152002740
|
96
96
|
- !ruby/object:Gem::Dependency
|
97
97
|
name: rspec-expectations
|
98
|
-
requirement: &
|
98
|
+
requirement: &2152051160 !ruby/object:Gem::Requirement
|
99
99
|
none: false
|
100
100
|
requirements:
|
101
101
|
- - ~>
|
@@ -103,10 +103,10 @@ dependencies:
|
|
103
103
|
version: '2.0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
|
-
version_requirements: *
|
106
|
+
version_requirements: *2152051160
|
107
107
|
- !ruby/object:Gem::Dependency
|
108
108
|
name: rr
|
109
|
-
requirement: &
|
109
|
+
requirement: &2152050700 !ruby/object:Gem::Requirement
|
110
110
|
none: false
|
111
111
|
requirements:
|
112
112
|
- - ~>
|
@@ -114,10 +114,10 @@ dependencies:
|
|
114
114
|
version: '1.0'
|
115
115
|
type: :development
|
116
116
|
prerelease: false
|
117
|
-
version_requirements: *
|
117
|
+
version_requirements: *2152050700
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
119
|
name: faker
|
120
|
-
requirement: &
|
120
|
+
requirement: &2152050240 !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
123
|
- - ~>
|
@@ -125,10 +125,10 @@ dependencies:
|
|
125
125
|
version: '0.9'
|
126
126
|
type: :development
|
127
127
|
prerelease: false
|
128
|
-
version_requirements: *
|
128
|
+
version_requirements: *2152050240
|
129
129
|
- !ruby/object:Gem::Dependency
|
130
130
|
name: yard
|
131
|
-
requirement: &
|
131
|
+
requirement: &2152049780 !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
134
134
|
- - ~>
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
version: '0.7'
|
137
137
|
type: :development
|
138
138
|
prerelease: false
|
139
|
-
version_requirements: *
|
139
|
+
version_requirements: *2152049780
|
140
140
|
description: Bluepill keeps your daemons up while taking up as little resources as
|
141
141
|
possible. After all you probably want the resources of your server to be used by
|
142
142
|
whatever daemons you are running rather than the thing that's supposed to make sure
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- lib/bluepill/triggers/flapping.rb
|
194
194
|
- lib/bluepill/util/rotational_array.rb
|
195
195
|
- lib/bluepill/version.rb
|
196
|
+
- local-bluepill
|
196
197
|
- spec/lib/bluepill/logger_spec.rb
|
197
198
|
- spec/lib/bluepill/process_statistics_spec.rb
|
198
199
|
- spec/lib/bluepill/system_spec.rb
|