procodile 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6afcf104b9bc4268bc21c634075b7cd4c8ef8d33
4
- data.tar.gz: a46fd5857741a36d7d2584a4d4cea4ed07c5dbfa
3
+ metadata.gz: e1bd3a47f7f701a8430b69a48bb9f114a6e6f7a8
4
+ data.tar.gz: e1df71b29eb1f5836132539beb2691a85f390301
5
5
  SHA512:
6
- metadata.gz: 85ea38210c9cf42dde381b7ed2a8966578047356cfdd6deed42942ea49f6880a8fb32317b00d98586054925ab7d8acbcc716577db27b1a8796aaa506dd195a7a
7
- data.tar.gz: d43970fcd524920fae6d7980546de10c9f0980354d8e80cf33d2569d8d90253ce1cafd7b85d98db865aac982aaf9ca61123492d0f774f798d7ad0d16024cc3fb
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
@@ -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.")
@@ -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 active_instances.size > process.quantity
235
- quantity_to_stop = active_instances.size - process.quantity
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] = active_instances.last(quantity_to_stop).each(&:stop)
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 active_instances.size < process.quantity
243
- quantity_needed = process.quantity - active_instances.size
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
@@ -1,3 +1,3 @@
1
1
  module Procodile
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
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
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-20 00:00:00.000000000 Z
11
+ date: 2016-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json