procman 1.0.0
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/Procfile +10 -0
- data/bin/procman +8 -0
- data/lib/proc_man/process.rb +27 -0
- data/lib/proc_man/procfile.rb +13 -0
- data/lib/proc_man.rb +42 -0
- data/proman.gemspec +18 -0
- metadata +53 -0
data/Procfile
ADDED
data/bin/procman
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
module ProcMan
|
2
|
+
class Process
|
3
|
+
|
4
|
+
def initialize(name)
|
5
|
+
@name = name
|
6
|
+
end
|
7
|
+
|
8
|
+
def name
|
9
|
+
@name
|
10
|
+
end
|
11
|
+
|
12
|
+
def method_missing(method, &block)
|
13
|
+
if block_given?
|
14
|
+
instance_variable_set("@#{method}", block)
|
15
|
+
elsif block = instance_variable_get("@#{method}")
|
16
|
+
block.call
|
17
|
+
else
|
18
|
+
return false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def defined_method?(name)
|
23
|
+
instance_variable_get("@#{name}").is_a?(Proc)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
data/lib/proc_man.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'proc_man/process'
|
2
|
+
require 'proc_man/procfile'
|
3
|
+
|
4
|
+
module ProcMan
|
5
|
+
|
6
|
+
VERSION = '1.0.0'
|
7
|
+
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def load_procfile(path)
|
13
|
+
if File.file?(path)
|
14
|
+
ProcMan::Procfile.class_eval(File.read(path))
|
15
|
+
puts "\e[35mProcfile loaded from #{path}\e[0m"
|
16
|
+
else
|
17
|
+
raise Error, "Procfile not found at #{path}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def processes
|
22
|
+
@processes ||= Array.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def run(method)
|
26
|
+
load_procfile(File.expand_path('./Procfile'))
|
27
|
+
if method.nil?
|
28
|
+
raise Error, "Command to execute was not specified. For example, pass 'start' to start processes."
|
29
|
+
else
|
30
|
+
for process in self.processes
|
31
|
+
if process.defined_method?(method)
|
32
|
+
puts "\e[33m#{method.capitalize}ing #{process.name}\e[0m"
|
33
|
+
process.send(method)
|
34
|
+
else
|
35
|
+
puts "\e[31mThe #{process.name} process does not implement a '#{method}' method\e[0m"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/proman.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __FILE__))
|
2
|
+
require 'proc_man'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'procman'
|
6
|
+
s.version = ProcMan::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.summary = "A very very simple library for starting/stopping/restarting processes for a Ruby application"
|
9
|
+
s.description = s.summary
|
10
|
+
s.files = Dir["**/*"]
|
11
|
+
s.bindir = "bin"
|
12
|
+
s.executables << 'procman'
|
13
|
+
s.require_path = 'lib'
|
14
|
+
s.has_rdoc = false
|
15
|
+
s.author = "Adam Cooke"
|
16
|
+
s.email = "adam@atechmedia.com"
|
17
|
+
s.homepage = "http://atechmedia.com"
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: procman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Adam Cooke
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-23 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A very very simple library for starting/stopping/restarting processes
|
15
|
+
for a Ruby application
|
16
|
+
email: adam@atechmedia.com
|
17
|
+
executables:
|
18
|
+
- procman
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- bin/procman
|
23
|
+
- lib/proc_man/process.rb
|
24
|
+
- lib/proc_man/procfile.rb
|
25
|
+
- lib/proc_man.rb
|
26
|
+
- Procfile
|
27
|
+
- proman.gemspec
|
28
|
+
homepage: http://atechmedia.com
|
29
|
+
licenses: []
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.8.23
|
49
|
+
signing_key:
|
50
|
+
specification_version: 3
|
51
|
+
summary: A very very simple library for starting/stopping/restarting processes for
|
52
|
+
a Ruby application
|
53
|
+
test_files: []
|