procodile 1.0.4 → 1.0.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.
- checksums.yaml +4 -4
- data/bin/procodile +20 -2
- data/lib/procodile/instance.rb +2 -0
- data/lib/procodile/supervisor.rb +5 -6
- data/lib/procodile/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1bd3a47f7f701a8430b69a48bb9f114a6e6f7a8
|
4
|
+
data.tar.gz: e1df71b29eb1f5836132539beb2691a85f390301
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f09564099dc0dabd736a48677b7f475a6ef1d723f95aabcd9c7470277ad6d411da63b75ba02041ef4f9c3d5dfb6425c0296019cb216a3489437e67b42ba0e83c
|
7
|
+
data.tar.gz: 4fe1b93764fb2a2c041d55ce996ebd6003c71df83d14da3540a3184ceae9566ed7fff0a32c8b37ec7637dd98f0a1dbf8bbb0847f0462cb3f5c0bcb990f3ab413
|
data/bin/procodile
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
$:.unshift(File.expand_path('../../lib', __FILE__))
|
3
2
|
|
3
|
+
require 'yaml'
|
4
|
+
global_config_path = ENV['PROCODILE_CONFIG'] || "/etc/procodile"
|
5
|
+
if File.exist?(global_config_path)
|
6
|
+
global_config = YAML.load_file(global_config_path)
|
7
|
+
else
|
8
|
+
global_config = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
if global_config['user'] && ENV['USER'] != global_config['user']
|
12
|
+
if global_config['user_reexec']
|
13
|
+
$stderr.puts "\e[31mProcodile must be run as #{global_config['user']}. Re-executing as #{global_config['user']}...\e[0m"
|
14
|
+
exec "sudo -u #{global_config['user']} -- #{$0} #{ARGV.join(' ')}"
|
15
|
+
else
|
16
|
+
$stderr.puts "\e[31mError: Procodile must be run as #{global_config['user']}\e[0m"
|
17
|
+
exit 1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
$:.unshift(File.expand_path('../../lib', __FILE__))
|
4
22
|
require 'optparse'
|
5
23
|
require 'fileutils'
|
6
24
|
require 'procodile'
|
@@ -33,7 +51,7 @@ end
|
|
33
51
|
|
34
52
|
begin
|
35
53
|
if command != 'help'
|
36
|
-
cli.config = Procodile::Config.new(options[:root] ? File.expand_path(options[:root]) : FileUtils.pwd)
|
54
|
+
cli.config = Procodile::Config.new(options[:root] ? File.expand_path(options[:root]) : global_config['root'] || FileUtils.pwd)
|
37
55
|
end
|
38
56
|
cli.run(command)
|
39
57
|
rescue Procodile::Error => e
|
data/lib/procodile/instance.rb
CHANGED
@@ -46,6 +46,7 @@ module Procodile
|
|
46
46
|
#
|
47
47
|
def environment_variables
|
48
48
|
vars = @process.environment_variables.merge({
|
49
|
+
'PROC_NAME' => self.description,
|
49
50
|
'PID_FILE' => self.pid_file_path,
|
50
51
|
'APP_ROOT' => @process.config.root
|
51
52
|
})
|
@@ -188,6 +189,7 @@ module Procodile
|
|
188
189
|
when 'usr1', 'usr2'
|
189
190
|
if running?
|
190
191
|
::Process.kill(@process.restart_mode.upcase, @pid)
|
192
|
+
@tag = @supervisor.tag if @supervisor.tag
|
191
193
|
Procodile.log(@process.log_color, description, "Sent #{@process.restart_mode.upcase} signal to process #{@pid}")
|
192
194
|
else
|
193
195
|
Procodile.log(@process.log_color, description, "Process not running already. Starting it.")
|
data/lib/procodile/supervisor.rb
CHANGED
@@ -228,19 +228,18 @@ module Procodile
|
|
228
228
|
{:started => [], :stopped => []}.tap do |status|
|
229
229
|
@processes.each do |process, instances|
|
230
230
|
next if processes && !processes.include?(process.name)
|
231
|
-
active_instances = instances.select(&:running?)
|
232
231
|
|
233
232
|
if type == :both || type == :stopped
|
234
|
-
if
|
235
|
-
quantity_to_stop =
|
233
|
+
if instances.size > process.quantity
|
234
|
+
quantity_to_stop = instances.size - process.quantity
|
236
235
|
Procodile.log nil, "system", "Stopping #{quantity_to_stop} #{process.name} process(es)"
|
237
|
-
status[:stopped] =
|
236
|
+
status[:stopped] = instances.last(quantity_to_stop).each(&:stop)
|
238
237
|
end
|
239
238
|
end
|
240
239
|
|
241
240
|
if type == :both || type == :started
|
242
|
-
if
|
243
|
-
quantity_needed = process.quantity -
|
241
|
+
if instances.size < process.quantity
|
242
|
+
quantity_needed = process.quantity - instances.size
|
244
243
|
Procodile.log nil, "system", "Starting #{quantity_needed} more #{process.name} process(es)"
|
245
244
|
status[:started] = process.generate_instances(self, quantity_needed).each(&:start)
|
246
245
|
end
|
data/lib/procodile/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procodile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|