foreman 0.4.7 → 0.5.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/README.markdown +8 -4
- data/export/upstart/process.conf.erb +1 -1
- data/lib/foreman.rb +1 -1
- data/lib/foreman/cli.rb +10 -12
- data/lib/foreman/export/base.rb +6 -0
- data/lib/foreman/export/inittab.rb +10 -3
- data/lib/foreman/export/upstart.rb +1 -0
- metadata +5 -5
data/README.markdown
CHANGED
@@ -43,13 +43,17 @@ The following options control how the application is run:
|
|
43
43
|
Use this name rather than the application's root directory name as the
|
44
44
|
name of the application when exporting.
|
45
45
|
|
46
|
-
* `-l`, `--log`:
|
47
|
-
Specify the directory to place process logs in.
|
48
|
-
|
49
46
|
* `-c`, `--concurrency`:
|
50
47
|
Specify the number of each process type to run. The value passed in
|
51
48
|
should be in the format `process=num,process=num`
|
52
49
|
|
50
|
+
* `-l`, `--log`:
|
51
|
+
Specify the directory to place process logs in.
|
52
|
+
|
53
|
+
* `-p`, `--port`:
|
54
|
+
Specify which port to use as the base for this application. Should be
|
55
|
+
a multiple of 1000.
|
56
|
+
|
53
57
|
* `-u`, `--user`:
|
54
58
|
Specify the user the application should be run as. Defaults to the
|
55
59
|
app name
|
@@ -58,7 +62,7 @@ The following options control how the application is run:
|
|
58
62
|
|
59
63
|
These options control all modes of foreman's operation.
|
60
64
|
|
61
|
-
* `-
|
65
|
+
* `-f`, `--procfile`
|
62
66
|
Specify an alternate location for the application's Procfile. This file's
|
63
67
|
containing directory will be assumed to be the root directory of the
|
64
68
|
application.
|
@@ -3,4 +3,4 @@ stop on stopping <%= app %>-<%= process.name %>
|
|
3
3
|
respawn
|
4
4
|
|
5
5
|
chdir <%= engine.directory %>
|
6
|
-
exec su <%= user %> -c "<%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1"
|
6
|
+
exec su <%= user %> -c "PORT=<%= port %> <%= process.command %> >> <%= log_root %>/<%=process.name%>-<%=num%>.log 2>&1"
|
data/lib/foreman.rb
CHANGED
data/lib/foreman/cli.rb
CHANGED
@@ -5,7 +5,7 @@ require "thor"
|
|
5
5
|
|
6
6
|
class Foreman::CLI < Thor
|
7
7
|
|
8
|
-
class_option :procfile, :type => :string, :aliases => "-
|
8
|
+
class_option :procfile, :type => :string, :aliases => "-f", :desc => "Default: ./Procfile"
|
9
9
|
|
10
10
|
desc "start [PROCESS]", "Start the application, or a specific process"
|
11
11
|
|
@@ -13,7 +13,7 @@ class Foreman::CLI < Thor
|
|
13
13
|
|
14
14
|
def start(process=nil)
|
15
15
|
check_procfile!
|
16
|
-
|
16
|
+
|
17
17
|
if process
|
18
18
|
engine.execute(process)
|
19
19
|
elsif options[:screen]
|
@@ -25,11 +25,13 @@ class Foreman::CLI < Thor
|
|
25
25
|
|
26
26
|
desc "export FORMAT LOCATION", "Export the application to another process management format"
|
27
27
|
|
28
|
-
method_option :app, :type => :string,
|
29
|
-
method_option :log, :type => :string,
|
30
|
-
method_option :
|
31
|
-
method_option :
|
28
|
+
method_option :app, :type => :string, :aliases => "-a"
|
29
|
+
method_option :log, :type => :string, :aliases => "-l"
|
30
|
+
method_option :port, :type => :numeric, :aliases => "-p"
|
31
|
+
method_option :user, :type => :string, :aliases => "-u"
|
32
|
+
method_option :concurrency, :type => :string, :aliases => "-c",
|
32
33
|
:banner => '"alpha=5,bar=3"'
|
34
|
+
|
33
35
|
def export(format, location=nil)
|
34
36
|
check_procfile!
|
35
37
|
|
@@ -39,12 +41,8 @@ class Foreman::CLI < Thor
|
|
39
41
|
else error "Unknown export format: #{format}."
|
40
42
|
end
|
41
43
|
|
42
|
-
formatter.new(engine).export(location,
|
43
|
-
|
44
|
-
:user => options[:user],
|
45
|
-
:log => options[:log],
|
46
|
-
:concurrency => options[:concurrency]
|
47
|
-
)
|
44
|
+
formatter.new(engine).export(location, options)
|
45
|
+
|
48
46
|
rescue Foreman::Export::Exception => ex
|
49
47
|
error ex.message
|
50
48
|
end
|
data/lib/foreman/export/base.rb
CHANGED
@@ -36,6 +36,12 @@ private ######################################################################
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
def port_for(base_port, app, num)
|
40
|
+
base_port ||= 5000
|
41
|
+
offset = engine.processes.keys.sort.index(app) * 100
|
42
|
+
base_port.to_i + offset + num - 1
|
43
|
+
end
|
44
|
+
|
39
45
|
def write_file(filename, contents)
|
40
46
|
say "writing: #{filename}"
|
41
47
|
|
@@ -11,10 +11,17 @@ class Foreman::Export::Inittab < Foreman::Export::Base
|
|
11
11
|
|
12
12
|
inittab = []
|
13
13
|
inittab << "# ----- foreman #{app} processes -----"
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
|
15
|
+
engine.processes.values.inject(1) do |index, process|
|
16
|
+
1.upto(concurrency[process.name]) do |num|
|
17
|
+
id = app.slice(0, 2).upcase + sprintf("%02d", index)
|
18
|
+
port = port_for(options[:port], process.name, num)
|
19
|
+
inittab << "#{id}:4:respawn:/bin/su - #{user} -c 'PORT=#{port} #{process.command} >> #{log_root}/#{process.name}-#{num}.log 2>&1'"
|
20
|
+
index += 1
|
21
|
+
end
|
22
|
+
index
|
17
23
|
end
|
24
|
+
|
18
25
|
inittab << "# ----- end foreman #{app} processes -----"
|
19
26
|
|
20
27
|
inittab = inittab.join("\n") + "\n"
|
@@ -31,6 +31,7 @@ class Foreman::Export::Upstart < Foreman::Export::Base
|
|
31
31
|
write_file "#{location}/#{app}-#{process.name}.conf", process_master_config
|
32
32
|
|
33
33
|
1.upto(concurrency[process.name]) do |num|
|
34
|
+
port = port_for(options[:port], process.name, num)
|
34
35
|
process_config = ERB.new(process_template).result(binding)
|
35
36
|
write_file "#{location}/#{app}-#{process.name}-#{num}.conf", process_config
|
36
37
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 5
|
9
|
+
- 0
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Dollar
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-06-
|
18
|
+
date: 2010-06-30 00:00:00 -04:00
|
19
19
|
default_executable: foreman
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|