Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

Commit

Permalink
Drop a pidfile at startup.
Browse files Browse the repository at this point in the history
Should nuke it if the app stops.  Appends port number for multi-tenant
deployments.
  • Loading branch information
leftathome committed Jun 6, 2013
1 parent 6d0ae6e commit af63dcf
Showing 1 changed file with 15 additions and 0 deletions.
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]

0 comments on commit af63dcf

Please sign in to comment.