autoparts
autoparts copied to clipboard
pid checks in running? should verify that the process is indeed alive
The following fails after a restart because pid isn't cleaned up correctly on box shut down.
https://github.com/nitrous-io/autoparts/blob/master/lib/autoparts/packages/apache2.rb#L85
def running?
pid = Path.var + name + "run" + "httpd.pid"
pid.exist?
end
Do something like this instead:
https://github.com/nitrous-io/autoparts/blob/master/lib/autoparts/packages/mongodb.rb#L84
def running?
if mongod_pid_file_path.exist?
pid = File.read(mongod_pid_file_path).strip
if pid.length > 0 && `ps -o cmd= #{pid}`.include?(mongod_path.basename.to_s)
return true
end
end
false
end