Skip to content

Commit

Permalink
Merge pull request #21 from leftathome/manage_pidfile
Browse files Browse the repository at this point in the history
App should drop a pidfile at startup.
  • Loading branch information
Brian Scott committed Jun 6, 2013
2 parents 6c49cd1 + af63dcf commit 98f30dd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
15 changes: 15 additions & 0 deletions bin/chef-rundeck
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ class ChefRundeckCLI
:long => "--port PORT",
:description => "The port to run on, default 9980",
:default => 9980

option :pidfile,
:short => "-P FILE",
:long => "--pidfile FILE",
:description => "Prefix for our PID file, default: /var/run/chef-rundeck- ('PORT.pid' will be added)",
:default => "/var/run/chef-rundeck"
end

cli = ChefRundeckCLI.new
Expand All @@ -57,5 +63,14 @@ ChefRundeck.username = cli.config[:username]
ChefRundeck.web_ui_url = cli.config[:web_ui_url]
ChefRundeck.configure

begin
pid = "#{cli.config[:pidfile]}-#{cli.config[:port]}.pid"
puts "Writing to #{pid}"
File.open(pid, 'w'){ |f| f.write(Process.pid) }
at_exit { File.delete(pid) if File.exist?(pid) }
rescue Exception => e
puts "== Error writing pid file #{pid}!"
end

ChefRundeck.run! :host => 'localhost', :port => cli.config[:port]

4 changes: 3 additions & 1 deletion spec/support/client.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
log_level :info
log_level :debug
log_location STDOUT
chef_server_url "https://api.opscode.com/organizations/chef-rundeck"
web_ui_url "https://manage.opscode.com"
client_key "#{ENV["TRAVIS_BUILD_DIR"]}" + "/spec/support/travis.pem"
node_name "travis"
username "travis"

0 comments on commit 98f30dd

Please sign in to comment.