Skip to content

Commit

Permalink
Merge pull request ddollar#329 from kentaro/permit-underscore-in-proc…
Browse files Browse the repository at this point in the history
…file

Permit hyphen for command name in Procfile
  • Loading branch information
ddollar committed Apr 14, 2013
2 parents 93daebb + 8d1e3a8 commit eaed989
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/foreman/procfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def to_s

def parse(filename)
File.read(filename).gsub("\r\n","\n").split("\n").map do |line|
if line =~ /^([A-Za-z0-9_]+):\s*(.+)$/
if line =~ /^([A-Za-z0-9_-]+):\s*(.+)$/
[$1, $2]
end
end.compact
Expand Down
2 changes: 1 addition & 1 deletion spec/foreman/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
describe "check" do
it "with a valid Procfile displays the jobs" do
write_procfile
foreman("check").should == "valid procfile detected (alpha, bravo)\n"
foreman("check").should == "valid procfile detected (alpha, bravo, foo_bar, foo-bar)\n"
end

it "with a blank Procfile displays an error" do
Expand Down
4 changes: 4 additions & 0 deletions spec/foreman/export/upstart_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
mock(FileUtils).rm("/tmp/init/app-alpha-1.conf")
mock(FileUtils).rm("/tmp/init/app-bravo.conf")
mock(FileUtils).rm("/tmp/init/app-bravo-1.conf")
mock(FileUtils).rm("/tmp/init/app-foo-bar.conf")
mock(FileUtils).rm("/tmp/init/app-foo-bar-1.conf")
mock(FileUtils).rm("/tmp/init/app-foo_bar.conf")
mock(FileUtils).rm("/tmp/init/app-foo_bar-1.conf")

upstart.export
upstart.export
Expand Down
6 changes: 4 additions & 2 deletions spec/foreman/procfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
it "loads a passed-in Procfile" do
write_procfile
procfile = Foreman::Procfile.new("Procfile")
procfile["alpha"].should == "./alpha"
procfile["bravo"].should == "./bravo"
procfile["alpha"].should == "./alpha"
procfile["bravo"].should == "./bravo"
procfile["foo-bar"].should == "./foo-bar"
procfile["foo_bar"].should == "./foo_bar"
end

it "can have a process appended to it" do
Expand Down
35 changes: 35 additions & 0 deletions spec/resources/export/bluepill/app.pill
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,40 @@ Bluepill.application("app", :foreground => false, :log_file => "/var/log/bluepil
process.group = "app-bravo"
end

app.process("foo_bar-1") do |process|
process.start_command = "./foo_bar"

process.working_dir = "/tmp/app"
process.daemonize = true
process.environment = {"PORT"=>"5200"}
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
process.stop_grace_time = 45.seconds

process.stdout = process.stderr = "/var/log/app/app-foo_bar-1.log"

process.monitor_children do |children|
children.stop_command "kill {{PID}}"
end

process.group = "app-foo_bar"
end

app.process("foo-bar-1") do |process|
process.start_command = "./foo-bar"

process.working_dir = "/tmp/app"
process.daemonize = true
process.environment = {"PORT"=>"5300"}
process.stop_signals = [:quit, 30.seconds, :term, 5.seconds, :kill]
process.stop_grace_time = 45.seconds

process.stdout = process.stderr = "/var/log/app/app-foo-bar-1.log"

process.monitor_children do |children|

children.stop_command "kill {{PID}}"
end

process.group = "app-foo-bar"
end
end
2 changes: 2 additions & 0 deletions spec/resources/export/inittab/inittab.default
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# ----- foreman app processes -----
AP01:4:respawn:/bin/su - app -c 'cd /tmp/app;export PORT=5000;./alpha >> /var/log/app/alpha-1.log 2>&1'
AP02:4:respawn:/bin/su - app -c 'cd /tmp/app;export PORT=5100;./bravo >> /var/log/app/bravo-1.log 2>&1'
AP03:4:respawn:/bin/su - app -c 'cd /tmp/app;export PORT=5200;./foo_bar >> /var/log/app/foo_bar-1.log 2>&1'
AP04:4:respawn:/bin/su - app -c 'cd /tmp/app;export PORT=5300;./foo-bar >> /var/log/app/foo-bar-1.log 2>&1'
# ----- end foreman app processes -----
22 changes: 21 additions & 1 deletion spec/resources/export/supervisord/app-alpha-1.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,26 @@ stderr_logfile=/var/log/app/bravo-1.error.log
user=app
directory=/tmp/app
environment=PORT=5100
[program:app-foo_bar-1]
command=./foo_bar
autostart=true
autorestart=true
stopsignal=QUIT
stdout_logfile=/var/log/app/foo_bar-1.log
stderr_logfile=/var/log/app/foo_bar-1.error.log
user=app
directory=/tmp/app
environment=PORT=5200
[program:app-foo-bar-1]
command=./foo-bar
autostart=true
autorestart=true
stopsignal=QUIT
stdout_logfile=/var/log/app/foo-bar-1.log
stderr_logfile=/var/log/app/foo-bar-1.error.log
user=app
directory=/tmp/app
environment=PORT=5300

[group:app]
programs=app-alpha-1,app-bravo-1
programs=app-alpha-1,app-bravo-1,app-foo_bar-1,app-foo-bar-1
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ def write_procfile(procfile="Procfile", alpha_env="")
file.puts "alpha: ./alpha" + " #{alpha_env}".rstrip
file.puts "\n"
file.puts "bravo:\t./bravo"
file.puts "foo_bar:\t./foo_bar"
file.puts "foo-bar:\t./foo-bar"
end
File.expand_path(procfile)
end
Expand Down

0 comments on commit eaed989

Please sign in to comment.