Forked from technicalpickles/restart_file_touched.rb
Created
January 17, 2012 18:13
-
-
Save daronco/1627909 to your computer and use it in GitHub Desktop.
A custom condition for God that checks for change in a file (usually tmp/restart.txt)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module God | |
module Conditions | |
class RestartFileTouched < PollCondition | |
attr_accessor :restart_file | |
def initialize | |
super | |
end | |
def process_start_time | |
Time.parse(`ps -o lstart -p #{self.watch.pid} --no-heading`) | |
end | |
def restart_file_modification_time | |
File.exists?(self.restart_file) ? File.mtime(self.restart_file) : Time.at(0) | |
end | |
def valid? | |
valid = true | |
valid &= complain("Attribute 'restart_file' must be specified", self) if self.restart_file.nil? | |
valid | |
end | |
def test | |
process_start_time < restart_file_modification_time | |
end | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module God | |
module Conditions | |
class RestartFileTouched < PollCondition | |
attr_accessor :restart_file | |
def initialize | |
super | |
end | |
def process_start_time | |
Time.parse(`ps -o lstart -p #{self.watch.pid} --no-heading`) | |
end | |
def restart_file_modification_time | |
File.exists?(self.restart_file) ? File.mtime(self.restart_file) : Time.at(0) | |
end | |
def valid? | |
valid = true | |
valid &= complain("Attribute 'restart_file' must be specified", self) if self.restart_file.nil? | |
valid | |
end | |
def test | |
process_start_time < restart_file_modification_time | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment