proctor 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rspec +2 -0
- data/Rakefile +7 -0
- data/bin/proctor +176 -2
- data/lib/proctor/app_file.rb +5 -0
- data/lib/proctor/app_global.rb +0 -0
- data/lib/proctor/config_file.rb +5 -0
- data/lib/proctor/config_global.rb +0 -0
- data/lib/proctor/export.rb +5 -0
- data/lib/proctor/job.rb +4 -0
- data/lib/proctor/manager.rb +5 -0
- data/lib/proctor/template.rb +5 -0
- data/lib/proctor/util.rb +12 -0
- data/lib/proctor/version.rb +1 -1
- data/lib/proctor.rb +2 -2
- data/proctor/Proctorfile +28 -0
- data/proctor/managers/MonitDefault.rb +0 -0
- data/proctor/managers/MonitFaye.rb +0 -0
- data/proctor/managers/MonitWeb.rb +0 -0
- data/proctor/managers/UpstartDefault.rb +0 -0
- data/proctor/managers/UpstartFaye.rb +0 -0
- data/proctor/managers/UpstartWeb.rb +0 -0
- data/proctor/templates/monit_default.erb +0 -0
- data/proctor/templates/monit_faye.erb +0 -0
- data/proctor/templates/monit_web.erb +0 -0
- data/proctor/templates/upstart_default.erb +0 -0
- data/proctor/templates/upstart_faye.erb +0 -0
- data/proctor/templates/upstart_web.erb +0 -0
- data/proctor.gemspec +5 -3
- data/spec/acceptance/help_spec.rb +20 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/aruba.rb +8 -0
- data/spec/unit/app_file_spec.rb +9 -0
- data/spec/unit/config_file_spec.rb +9 -0
- data/spec/unit/export_spec.rb +9 -0
- data/spec/unit/job_spec.rb +9 -0
- data/spec/unit/manager_spec.rb +11 -0
- data/spec/unit/template_spec.rb +7 -0
- metadata +65 -9
- data/test.yaml +0 -15
data/.gitignore
CHANGED
data/.rspec
ADDED
data/Rakefile
CHANGED
data/bin/proctor
CHANGED
@@ -1,5 +1,179 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
puts Time.now
|
3
|
+
$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
5
4
|
|
5
|
+
require 'rubygems'
|
6
|
+
require 'gli'
|
7
|
+
require 'proctor'
|
8
|
+
|
9
|
+
include GLI
|
10
|
+
|
11
|
+
# ---- global options ----------------------------------------------------
|
12
|
+
|
13
|
+
version Proctor::VERSION
|
14
|
+
program_desc 'proctor - an application process manager'
|
15
|
+
|
16
|
+
desc 'Root Directory'
|
17
|
+
default_value Dir.pwd
|
18
|
+
arg_name 'APP_ROOT'
|
19
|
+
flag [:d,'app-root']
|
20
|
+
|
21
|
+
desc 'Application Environment'
|
22
|
+
default_value "production"
|
23
|
+
arg_name 'ENV'
|
24
|
+
flag [:e,:environment]
|
25
|
+
|
26
|
+
desc 'Select Proctorfile'
|
27
|
+
default_value 'Proctorfile'
|
28
|
+
arg_name 'PROCTORFILE'
|
29
|
+
flag [:f,:proctorfile]
|
30
|
+
|
31
|
+
# ----- commands ---------------------------------------------------------
|
32
|
+
|
33
|
+
desc 'Validates your application Proctorfile'
|
34
|
+
command :check do |c|
|
35
|
+
c.action do |global_options,options,args|
|
36
|
+
puts "I AM IN CHECK"
|
37
|
+
# If you have any errors, just raise them
|
38
|
+
# raise "that command made no sense"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
desc 'Clean up generated files'
|
43
|
+
command :cleanup do |c|
|
44
|
+
c.action do |global_options,options,args|
|
45
|
+
puts "I AM IN CHECK"
|
46
|
+
# If you have any errors, just raise them
|
47
|
+
# raise "that command made no sense"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Exports the app to another tool'
|
52
|
+
arg_name 'Describe arguments to export here'
|
53
|
+
command :export do |c|
|
54
|
+
|
55
|
+
c.desc 'Format'
|
56
|
+
c.default_value 'upstart'
|
57
|
+
c.arg_name 'FORMAT'
|
58
|
+
c.flag [:f, :format]
|
59
|
+
|
60
|
+
c.desc 'Location'
|
61
|
+
c.default_value Dir.pwd
|
62
|
+
c.arg_name 'DIRECTORY'
|
63
|
+
c.flag [:d, :directory]
|
64
|
+
|
65
|
+
c.action do |global_options,options,args|
|
66
|
+
puts "I AM IN EXPORT"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
desc 'Generates local templates'
|
72
|
+
arg_name 'Describe arguments to init here'
|
73
|
+
command :generate do |c|
|
74
|
+
c.action do |global_options,options,args|
|
75
|
+
puts "I AM IN INIT"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
desc 'Creates a starter Procfile '
|
80
|
+
arg_name 'Describe arguments to init here'
|
81
|
+
command :init do |c|
|
82
|
+
c.action do |global_options,options,args|
|
83
|
+
puts "I AM IN INIT"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc 'Lists available formats'
|
88
|
+
arg_name 'Describe arguments to init here'
|
89
|
+
command :list do |c|
|
90
|
+
c.action do |global_options,options,args|
|
91
|
+
puts "I AM IN LIST"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
desc 'Run the application (development mode)'
|
96
|
+
arg_name 'Describe arguments to run here'
|
97
|
+
command :run do |c|
|
98
|
+
c.action do |global_options,options,args|
|
99
|
+
puts "I AM IN RUN"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
desc 'Start the application (production mode)'
|
104
|
+
arg_name 'Describe arguments to start here'
|
105
|
+
command :start do |c|
|
106
|
+
c.desc 'Describe a switch to start'
|
107
|
+
c.switch :s
|
108
|
+
|
109
|
+
c.desc 'Describe a flag to start'
|
110
|
+
c.default_value 'default'
|
111
|
+
c.flag :f
|
112
|
+
c.action do |global_options,options,args|
|
113
|
+
puts "I AM IN START"
|
114
|
+
|
115
|
+
# If you have any errors, just raise them
|
116
|
+
# raise "that command made no sense"
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
desc 'Stops the application (production mode)'
|
121
|
+
arg_name 'Describe arguments to start here'
|
122
|
+
command :stop do |c|
|
123
|
+
c.desc 'Describe a switch to start'
|
124
|
+
c.switch :s
|
125
|
+
|
126
|
+
c.desc 'Describe a flag to start'
|
127
|
+
c.default_value 'default'
|
128
|
+
c.flag :f
|
129
|
+
c.action do |global_options,options,args|
|
130
|
+
puts "I AM IN START"
|
131
|
+
|
132
|
+
# If you have any errors, just raise them
|
133
|
+
# raise "that command made no sense"
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
desc 'Shows the application status (production mode)'
|
138
|
+
arg_name 'Describe arguments to start here'
|
139
|
+
command :status do |c|
|
140
|
+
c.desc 'Describe a switch to start'
|
141
|
+
c.switch :s
|
142
|
+
|
143
|
+
c.desc 'Describe a flag to start'
|
144
|
+
c.default_value 'default'
|
145
|
+
c.flag :f
|
146
|
+
c.action do |global_options,options,args|
|
147
|
+
puts "I AM IN START"
|
148
|
+
|
149
|
+
# If you have any errors, just raise them
|
150
|
+
# raise "that command made no sense"
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
|
155
|
+
# ----- pre/post --------------------------------------------------------------
|
156
|
+
|
157
|
+
pre do |global,command,options,args|
|
158
|
+
# Pre logic here
|
159
|
+
# Return true to proceed; false to abort and not call the
|
160
|
+
# chosen command
|
161
|
+
# Use skips_pre before a command to skip this block
|
162
|
+
# on that command only
|
163
|
+
true
|
164
|
+
end
|
165
|
+
|
166
|
+
post do |global,command,options,args|
|
167
|
+
# Post logic here
|
168
|
+
# Use skips_post before a command to skip this
|
169
|
+
# block on that command only
|
170
|
+
end
|
171
|
+
|
172
|
+
on_error do |exception|
|
173
|
+
# return false to skip default error handling
|
174
|
+
true
|
175
|
+
end
|
176
|
+
|
177
|
+
# ----- run --------------------------------------------------------------------
|
178
|
+
|
179
|
+
exit GLI.run(ARGV)
|
File without changes
|
File without changes
|
data/lib/proctor/job.rb
ADDED
data/lib/proctor/util.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
|
2
|
+
# have this method, so we add it so we get resolved symlinks
|
3
|
+
# and compatibility
|
4
|
+
unless File.respond_to? :realpath
|
5
|
+
class File #:nodoc:
|
6
|
+
def self.realpath path
|
7
|
+
return realpath(File.readlink(path)) if symlink?(path)
|
8
|
+
path
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
#$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
data/lib/proctor/version.rb
CHANGED
data/lib/proctor.rb
CHANGED
data/proctor/Proctorfile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# vim: set ft=yaml:
|
2
|
+
---
|
3
|
+
# exports:
|
4
|
+
# upstart:
|
5
|
+
# start_command: "asdf"
|
6
|
+
# stop_command: "asdf"
|
7
|
+
# monit:
|
8
|
+
# reload_command: "asdf"
|
9
|
+
# procs:
|
10
|
+
# web:
|
11
|
+
# start_command: "asdf"
|
12
|
+
# stop_command: "asdf"
|
13
|
+
# faye:
|
14
|
+
# start_command: "asdf"
|
15
|
+
|
16
|
+
exports:
|
17
|
+
upstart:
|
18
|
+
start_command: "qwer"
|
19
|
+
stop_command: "qwer"
|
20
|
+
monit:
|
21
|
+
reload_command: "qwer"
|
22
|
+
procs:
|
23
|
+
web:
|
24
|
+
start_command: "qwer"
|
25
|
+
stop_command: "qwer"
|
26
|
+
faye:
|
27
|
+
start_command: "qwer"
|
28
|
+
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/proctor.gemspec
CHANGED
@@ -5,8 +5,8 @@ Gem::Specification.new do |gem|
|
|
5
5
|
|
6
6
|
gem.authors = ["andyl"]
|
7
7
|
gem.email = ["andy@r210.com"]
|
8
|
-
gem.description =
|
9
|
-
gem.summary =
|
8
|
+
gem.description = 'Proctor: a Process Manager'
|
9
|
+
gem.summary = 'Generates conf files for upstart and monit.'
|
10
10
|
gem.homepage = "http://github.com/andyl/proctor"
|
11
11
|
|
12
12
|
gem.files = `git ls-files`.split($\)
|
@@ -18,8 +18,10 @@ Gem::Specification.new do |gem|
|
|
18
18
|
|
19
19
|
gem.add_dependency('gli')
|
20
20
|
gem.add_dependency('foreman')
|
21
|
-
|
21
|
+
|
22
22
|
gem.add_development_dependency('rake')
|
23
23
|
gem.add_development_dependency('rdoc')
|
24
|
+
gem.add_development_dependency('rspec')
|
25
|
+
gem.add_development_dependency('aruba')
|
24
26
|
|
25
27
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'start/help' do
|
4
|
+
|
5
|
+
it 'returns text' do
|
6
|
+
start_simple
|
7
|
+
all_output.should include('proctor')
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'does not have an error' do
|
11
|
+
start_simple
|
12
|
+
all_output.should_not include('Error')
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'takes the help command' do
|
16
|
+
start_simple "help start"
|
17
|
+
all_output.should include('start')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
Bundler.setup
|
5
|
+
|
6
|
+
require 'proctor'
|
7
|
+
require 'aruba/api'
|
8
|
+
|
9
|
+
Dir['./spec/support/*.rb'].map {|f| require f}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
|
13
|
+
config.color_enabled = true
|
14
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
15
|
+
config.run_all_when_everything_filtered = true
|
16
|
+
config.filter_run :focus
|
17
|
+
config.include Aruba::Api, :example_group => {
|
18
|
+
:file_path => /spec\/acceptance/
|
19
|
+
}
|
20
|
+
config.before(:suite, :example_group => {
|
21
|
+
:file_path => /spec\/unit/
|
22
|
+
}) { $in_unit_spec_suite = true }
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../lib/proctor/app_file"
|
3
|
+
|
4
|
+
describe Proctor::AppFile do
|
5
|
+
it "should raise an error on bad format"
|
6
|
+
it "should have a list of valid object types"
|
7
|
+
it "should raise warnings for invalid objects"
|
8
|
+
it "should support a --no-warn field"
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../lib/proctor/config_file"
|
3
|
+
|
4
|
+
describe Proctor::ConfigFile do
|
5
|
+
it "should raise an error on bad format"
|
6
|
+
it "should have a list of valid object types"
|
7
|
+
it "should raise warnings for invalid objects"
|
8
|
+
it "should support a --no-warn field"
|
9
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require_relative "../../lib/proctor/manager"
|
3
|
+
|
4
|
+
describe Proctor::Manager do
|
5
|
+
it "should support a standard set of commands (export, cleanup, start, stop, reload, restart, status)"
|
6
|
+
it "should have a field 'support' which list valid commands"
|
7
|
+
it "should know a format and an app"
|
8
|
+
it "should support a default type for app"
|
9
|
+
it "should know the target directory for deploying"
|
10
|
+
it "should know about dependencies" # run depends on export
|
11
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proctor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: gli
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
|
-
name:
|
47
|
+
name: rake
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
49
49
|
none: false
|
50
50
|
requirements:
|
@@ -60,7 +60,7 @@ dependencies:
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
63
|
+
name: rdoc
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
65
65
|
none: false
|
66
66
|
requirements:
|
@@ -76,7 +76,23 @@ dependencies:
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
- !ruby/object:Gem::Dependency
|
79
|
-
name:
|
79
|
+
name: rspec
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: aruba
|
80
96
|
requirement: !ruby/object:Gem::Requirement
|
81
97
|
none: false
|
82
98
|
requirements:
|
@@ -91,7 +107,7 @@ dependencies:
|
|
91
107
|
- - ! '>='
|
92
108
|
- !ruby/object:Gem::Version
|
93
109
|
version: '0'
|
94
|
-
description:
|
110
|
+
description: ! 'Proctor: a Process Manager'
|
95
111
|
email:
|
96
112
|
- andy@r210.com
|
97
113
|
executables:
|
@@ -100,15 +116,46 @@ extensions: []
|
|
100
116
|
extra_rdoc_files: []
|
101
117
|
files:
|
102
118
|
- .gitignore
|
119
|
+
- .rspec
|
103
120
|
- Gemfile
|
104
121
|
- LICENSE
|
105
122
|
- README.md
|
106
123
|
- Rakefile
|
107
124
|
- bin/proctor
|
108
125
|
- lib/proctor.rb
|
126
|
+
- lib/proctor/app_file.rb
|
127
|
+
- lib/proctor/app_global.rb
|
128
|
+
- lib/proctor/config_file.rb
|
129
|
+
- lib/proctor/config_global.rb
|
130
|
+
- lib/proctor/export.rb
|
131
|
+
- lib/proctor/job.rb
|
132
|
+
- lib/proctor/manager.rb
|
133
|
+
- lib/proctor/template.rb
|
134
|
+
- lib/proctor/util.rb
|
109
135
|
- lib/proctor/version.rb
|
110
136
|
- proctor.gemspec
|
111
|
-
-
|
137
|
+
- proctor/Proctorfile
|
138
|
+
- proctor/managers/MonitDefault.rb
|
139
|
+
- proctor/managers/MonitFaye.rb
|
140
|
+
- proctor/managers/MonitWeb.rb
|
141
|
+
- proctor/managers/UpstartDefault.rb
|
142
|
+
- proctor/managers/UpstartFaye.rb
|
143
|
+
- proctor/managers/UpstartWeb.rb
|
144
|
+
- proctor/templates/monit_default.erb
|
145
|
+
- proctor/templates/monit_faye.erb
|
146
|
+
- proctor/templates/monit_web.erb
|
147
|
+
- proctor/templates/upstart_default.erb
|
148
|
+
- proctor/templates/upstart_faye.erb
|
149
|
+
- proctor/templates/upstart_web.erb
|
150
|
+
- spec/acceptance/help_spec.rb
|
151
|
+
- spec/spec_helper.rb
|
152
|
+
- spec/support/aruba.rb
|
153
|
+
- spec/unit/app_file_spec.rb
|
154
|
+
- spec/unit/config_file_spec.rb
|
155
|
+
- spec/unit/export_spec.rb
|
156
|
+
- spec/unit/job_spec.rb
|
157
|
+
- spec/unit/manager_spec.rb
|
158
|
+
- spec/unit/template_spec.rb
|
112
159
|
homepage: http://github.com/andyl/proctor
|
113
160
|
licenses: []
|
114
161
|
post_install_message:
|
@@ -132,5 +179,14 @@ rubyforge_project:
|
|
132
179
|
rubygems_version: 1.8.23
|
133
180
|
signing_key:
|
134
181
|
specification_version: 3
|
135
|
-
summary:
|
136
|
-
test_files:
|
182
|
+
summary: Generates conf files for upstart and monit.
|
183
|
+
test_files:
|
184
|
+
- spec/acceptance/help_spec.rb
|
185
|
+
- spec/spec_helper.rb
|
186
|
+
- spec/support/aruba.rb
|
187
|
+
- spec/unit/app_file_spec.rb
|
188
|
+
- spec/unit/config_file_spec.rb
|
189
|
+
- spec/unit/export_spec.rb
|
190
|
+
- spec/unit/job_spec.rb
|
191
|
+
- spec/unit/manager_spec.rb
|
192
|
+
- spec/unit/template_spec.rb
|