procman 1.9.1 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Procfile.template +7 -7
- data/README.md +9 -7
- data/bin/procman +4 -3
- data/lib/proc_man.rb +10 -10
- data/lib/proc_man/capistrano.rb +5 -5
- data/lib/proc_man/capistrano3.rb +6 -6
- data/lib/proc_man/constraint.rb +5 -5
- data/lib/proc_man/process.rb +21 -16
- data/lib/proc_man/procfile.rb +2 -2
- data/procman-1.9.1.gem +0 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a12f290cb60dba235f7e2e415a99a215b5d6249
|
4
|
+
data.tar.gz: b0dc610e93bd0994e360d0877df5bd87e6cf92eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 969dabeaa186a1db76054907e357d88ff5a9e4a54bcbb9a1beed63d14c3bcd9933bde6d725e2cf8553260043299faa537338d4e892b3b98c75a524e69e3c0799
|
7
|
+
data.tar.gz: 3bd880a25a15c4edc33923c2c53549b50df5cd05d4f7521282e56ca889506ebedd5e793fc7b974014138f9e0552a90dfcd2a86f38602f40eb390575ac3722f6b
|
data/Procfile.template
CHANGED
@@ -5,20 +5,20 @@ process :example_worker do
|
|
5
5
|
|
6
6
|
# Only action this process in development
|
7
7
|
# constraint :environment => 'development'
|
8
|
-
|
8
|
+
|
9
9
|
# Define the action to be carried out when this process should start
|
10
10
|
start do
|
11
|
-
|
11
|
+
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
# Define the action to be carried out when this process should stop
|
15
15
|
stop do
|
16
|
-
|
16
|
+
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
# Define the action to be carried out when this process should restart
|
20
20
|
restart do
|
21
|
-
|
21
|
+
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
data/README.md
CHANGED
@@ -13,12 +13,14 @@ your processes.
|
|
13
13
|
## Setting up
|
14
14
|
|
15
15
|
If you're using Bundler (you should be) and wish to use procman, just include it within
|
16
|
-
your Gemfile and run `bundle` to install it.
|
16
|
+
your Gemfile and run `bundle` to install it.
|
17
17
|
|
18
18
|
```ruby
|
19
19
|
gem 'procman'
|
20
20
|
```
|
21
21
|
|
22
|
+
[![Gem Version](https://badge.fury.io/rb/procman.svg)](http://badge.fury.io/rb/procman)
|
23
|
+
|
22
24
|
Once installed, you can execute commands as shown below but you should prefix `bundle exec`
|
23
25
|
to the start of the command.
|
24
26
|
|
@@ -46,11 +48,11 @@ process :unicorn do
|
|
46
48
|
start do
|
47
49
|
system("umask 002 && bundle exec unicorn_rails -E #{environment} -c #{root}/config/unicorn.rb -D")
|
48
50
|
end
|
49
|
-
|
51
|
+
|
50
52
|
stop do
|
51
53
|
system("kill `cat #{root}/tmp/pids/unicorn.#{environment}.pid`")
|
52
54
|
end
|
53
|
-
|
55
|
+
|
54
56
|
restart { stop and start }
|
55
57
|
|
56
58
|
end
|
@@ -59,11 +61,11 @@ process :worker do
|
|
59
61
|
|
60
62
|
constraint :environment => 'production', :host => /\.production\.myapp\z/
|
61
63
|
constraint :environment => 'development', :host => /\.local\z/
|
62
|
-
|
64
|
+
|
63
65
|
start do
|
64
66
|
system("bundle exec rbg start -c #{root}/config/processes/worker.rb -E #{environment}")
|
65
67
|
end
|
66
|
-
|
68
|
+
|
67
69
|
stop do
|
68
70
|
system("bundle exec rbg stop -c #{root}/config/processes/worker.rb -E #{environment}")
|
69
71
|
end
|
@@ -71,7 +73,7 @@ process :worker do
|
|
71
73
|
restart do
|
72
74
|
system("bundle exec rbg reload -c #{root}/config/processes/worker.rb -E #{environment}")
|
73
75
|
end
|
74
|
-
|
76
|
+
|
75
77
|
end
|
76
78
|
```
|
77
79
|
|
@@ -85,7 +87,7 @@ for a specific process, it will always be included when your action is executed.
|
|
85
87
|
added, the process's action will only be invoked when at least one of the constraints is matched otherwise
|
86
88
|
it will be skipped.
|
87
89
|
|
88
|
-
Constraints are configured by adding `constraint` "rules" to your process definitions.
|
90
|
+
Constraints are configured by adding `constraint` "rules" to your process definitions.
|
89
91
|
|
90
92
|
```ruby
|
91
93
|
# execute always in production
|
data/bin/procman
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
$:.unshift(File.expand_path(File.join('../../lib'), __FILE__))
|
2
3
|
require 'proc_man'
|
3
4
|
begin
|
4
|
-
|
5
|
+
|
5
6
|
# Convert command line arguments into the appropriate ruby objects
|
6
7
|
args = ARGV.dup
|
7
8
|
final_args = []
|
@@ -14,7 +15,7 @@ begin
|
|
14
15
|
final_args << arg
|
15
16
|
end
|
16
17
|
end
|
17
|
-
|
18
|
+
|
18
19
|
command = final_args.first
|
19
20
|
case command
|
20
21
|
when 'init'
|
@@ -23,7 +24,7 @@ begin
|
|
23
24
|
# Execute the command
|
24
25
|
ProcMan.run(final_args.first, options)
|
25
26
|
end
|
26
|
-
|
27
|
+
|
27
28
|
rescue ProcMan::Error => e
|
28
29
|
puts "\e[31m" + e.message + "\e[0m"
|
29
30
|
Process.exit(1)
|
data/lib/proc_man.rb
CHANGED
@@ -3,13 +3,13 @@ require 'proc_man/procfile'
|
|
3
3
|
require 'proc_man/constraint'
|
4
4
|
|
5
5
|
module ProcMan
|
6
|
-
|
7
|
-
VERSION = '1.9.
|
8
|
-
|
6
|
+
|
7
|
+
VERSION = '1.9.2'
|
8
|
+
|
9
9
|
class Error < StandardError; end
|
10
|
-
|
10
|
+
|
11
11
|
class << self
|
12
|
-
|
12
|
+
|
13
13
|
def load_procfile(path)
|
14
14
|
if File.file?(path)
|
15
15
|
ProcMan::Procfile.class_eval(File.read(path))
|
@@ -18,13 +18,13 @@ module ProcMan
|
|
18
18
|
raise Error, "Procfile not found at #{path}"
|
19
19
|
end
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def processes
|
23
23
|
@processes ||= Array.new
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def run(method, options = {})
|
27
|
-
load_procfile(options[:procfile] || File.expand_path('./Procfile'))
|
27
|
+
load_procfile(options[:procfile] || options[:f] || File.expand_path('./Procfile'))
|
28
28
|
if method.nil?
|
29
29
|
raise Error, "Command to execute was not specified. For example, pass 'start' to start processes."
|
30
30
|
else
|
@@ -42,7 +42,7 @@ module ProcMan
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
# Create a new Procfile template in the current directory root
|
47
47
|
def init
|
48
48
|
path = File.expand_path('./Procfile')
|
@@ -54,6 +54,6 @@ module ProcMan
|
|
54
54
|
puts "\e[32mProcfile created at #{path}"
|
55
55
|
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
end
|
59
59
|
end
|
data/lib/proc_man/capistrano.rb
CHANGED
@@ -18,7 +18,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
18
18
|
after 'deploy:start', "procman:start"
|
19
19
|
after 'deploy:stop', "procman:stop"
|
20
20
|
after 'deploy:restart', "procman:restart"
|
21
|
-
|
21
|
+
|
22
22
|
def procman_command(command)
|
23
23
|
|
24
24
|
procfile_path = fetch(:procfile_path, "#{current_path}/Procfile")
|
@@ -33,11 +33,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
33
33
|
command = "sh -c \"cd #{current_path} && bundle exec procman #{command} --root #{current_path} --environment #{fetch(:rails_env, 'production')} #{procfile} #{process_opts} \""
|
34
34
|
|
35
35
|
if user = fetch(:procman_user, nil)
|
36
|
-
command = "sudo -u #{user} #{command}"
|
37
|
-
end
|
38
|
-
|
36
|
+
command = "sudo -u #{user} #{command}"
|
37
|
+
end
|
38
|
+
|
39
39
|
command
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
end
|
43
43
|
end
|
data/lib/proc_man/capistrano3.rb
CHANGED
@@ -29,7 +29,7 @@ namespace :procman do
|
|
29
29
|
end
|
30
30
|
|
31
31
|
after 'deploy:restart', "procman:restart"
|
32
|
-
|
32
|
+
|
33
33
|
def procman_command(command)
|
34
34
|
|
35
35
|
procfile_path = fetch(:procfile_path, "#{current_path}/Procfile")
|
@@ -45,16 +45,16 @@ namespace :procman do
|
|
45
45
|
command = "#{command} --root #{current_path} --environment #{fetch(:rails_env, 'production')} #{procfile} #{process_opts}"
|
46
46
|
|
47
47
|
if user = fetch(:procman_user, nil)
|
48
|
-
command = "sudo -u #{user} #{command}"
|
49
|
-
end
|
50
|
-
|
48
|
+
command = "sudo -u #{user} #{command}"
|
49
|
+
end
|
50
|
+
|
51
51
|
command
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
end
|
55
55
|
|
56
56
|
namespace :load do
|
57
57
|
task :defaults do
|
58
58
|
set :procman_roles, fetch(:procman_roles, [:app])
|
59
59
|
end
|
60
|
-
end
|
60
|
+
end
|
data/lib/proc_man/constraint.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
module ProcMan
|
2
2
|
class Constraint
|
3
|
-
|
3
|
+
|
4
4
|
def initialize(process, conditions)
|
5
5
|
@process = process
|
6
6
|
@conditions = conditions
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
def matches?
|
10
10
|
matches = 0
|
11
11
|
for key, value in @conditions
|
@@ -13,9 +13,9 @@ module ProcMan
|
|
13
13
|
end
|
14
14
|
@conditions.size > 0 && matches == @conditions.size
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
private
|
18
|
-
|
18
|
+
|
19
19
|
def compare(condition, value)
|
20
20
|
value = value.to_s.downcase
|
21
21
|
case condition
|
@@ -31,6 +31,6 @@ module ProcMan
|
|
31
31
|
false
|
32
32
|
end
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
end
|
36
36
|
end
|
data/lib/proc_man/process.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
1
|
module ProcMan
|
2
2
|
class Process
|
3
|
-
|
3
|
+
|
4
4
|
attr_writer :options
|
5
|
-
|
5
|
+
|
6
6
|
# Initializes the new process by receiving it's name
|
7
7
|
def initialize(name)
|
8
8
|
@name = name
|
9
9
|
@constraints = []
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
# Returns the name of the process
|
13
13
|
def name
|
14
14
|
@name
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# Returns a hash of options which the user has specified
|
18
18
|
def options
|
19
19
|
@options ||= {}
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
# Returns the current environment
|
23
23
|
def environment
|
24
24
|
self.options[:environment] || self.options[:e] || self.options[:env] || 'development'
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
# Returns the current root directory path
|
28
28
|
def root
|
29
29
|
@root ||= self.options[:root] || self.options[:r] || File.expand_path('./')
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
## Returns the current hostname of the machine executing this action
|
33
33
|
def host
|
34
34
|
@host ||= `hostname -f`.strip
|
@@ -39,25 +39,30 @@ module ProcMan
|
|
39
39
|
return @manual unless @manual.nil?
|
40
40
|
@manual = self.options[:processes] && self.options[:processes].split(',').include?(self.name.to_s)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
## Sets a constraint for this process
|
44
44
|
def constraint(hash = {})
|
45
45
|
@constraints << Constraint.new(self, hash)
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
|
+
## Return all processes which should execute
|
49
|
+
def processes_to_execute
|
50
|
+
(self.options[:processes] || self.options[:p])
|
51
|
+
end
|
52
|
+
|
48
53
|
# Specifies whether or not actions for this process should be executed
|
49
54
|
# in the current context.
|
50
55
|
def execute?
|
51
56
|
(@constraints.empty? || @constraints.any?(&:matches?)) &&
|
52
|
-
(self.
|
57
|
+
(self.processes_to_execute.nil? || self.processes_to_execute.split(',').include?(self.name.to_s))
|
53
58
|
end
|
54
|
-
|
59
|
+
|
55
60
|
# Specifies whether or not the provided method has been defined in the Procfile
|
56
61
|
# for this process.
|
57
62
|
def defined_method?(name)
|
58
63
|
instance_variable_get("@#{name}").is_a?(Proc)
|
59
64
|
end
|
60
|
-
|
65
|
+
|
61
66
|
# Stores and calls different process actions for this process. If there is no
|
62
67
|
# block provided and we don't have a method it will return false otherwise it
|
63
68
|
# will store or call the action as appropriate.
|
@@ -70,12 +75,12 @@ module ProcMan
|
|
70
75
|
return false
|
71
76
|
end
|
72
77
|
end
|
73
|
-
|
78
|
+
|
74
79
|
def run(command)
|
75
80
|
puts " \e[36m#{command}\e[0m"
|
76
81
|
system(command)
|
77
82
|
end
|
78
|
-
|
83
|
+
|
79
84
|
# A shortcut method for defining a set of RBG processes
|
80
85
|
def rbg(options = {})
|
81
86
|
options[:config_file] ||= "Rbgfile"
|
@@ -83,7 +88,7 @@ module ProcMan
|
|
83
88
|
stop { run("rbg stop -c #{root}/#{options[:config_file]} -E #{environment}") }
|
84
89
|
restart { run("rbg restart -c #{root}/#{options[:config_file]} -E #{environment}") }
|
85
90
|
end
|
86
|
-
|
91
|
+
|
87
92
|
# A shortcut method for defining a unicorn-like process
|
88
93
|
def unicorn(options = {})
|
89
94
|
options[:name] ||= 'unicorn'
|
@@ -93,6 +98,6 @@ module ProcMan
|
|
93
98
|
stop { run("kill `cat #{root}/#{options[:pid_path]}`") if File.exist?(options[:pid_path]) }
|
94
99
|
restart { run("kill -USR2 `cat #{root}/#{options[:pid_path]}`") if File.exist?(options[:pid_path]) }
|
95
100
|
end
|
96
|
-
|
101
|
+
|
97
102
|
end
|
98
103
|
end
|
data/lib/proc_man/procfile.rb
CHANGED
data/procman-1.9.1.gem
ADDED
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.9.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Cooke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A very very simple library for starting/stopping/restarting processes
|
14
14
|
for a Ruby application
|
@@ -29,6 +29,7 @@ files:
|
|
29
29
|
- lib/proc_man/process.rb
|
30
30
|
- lib/proc_man/procfile.rb
|
31
31
|
- lib/procman/capistrano.rb
|
32
|
+
- procman-1.9.1.gem
|
32
33
|
- procman.gemspec
|
33
34
|
homepage: http://atechmedia.com
|
34
35
|
licenses: []
|