# File lib/picnic/service_control.rb, line 249 def get_state # FIXME: This is a poor attempt at trying to fix a problem where occassionally # an empty pid_file is read, probably because it has not yet been # fully written. sleep 0.5 if File.exists? @options[:pid_file] pid = File.read(@options[:pid_file]).strip return :empty_pid unless pid and !pid.empty? # pid file exists but is empty state = `ps -p #{pid} -o state=`.strip if state == '' return :not_running elsif state == 'R' || state == 'S' return :ok else return :dead end else # TODO: scan through the process table to see if server is running without pid file return :missing_pid end end