-
-
Save geoffgarside/508286 to your computer and use it in GitHub Desktop.
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 FileTouched < PollCondition | |
attr_accessor :path | |
def initialize | |
super | |
self.path = nil | |
end | |
def valid? | |
valid = true | |
valid &= complain("Attribute 'path' must be specified", self) if self.path.nil? | |
valid | |
end | |
def test | |
return false unless File.exists?(self.path) | |
@mtime ||= File.mtime(self.path) # Set the mtime if we've not seen it before | |
if @mtime < (mtime = File.mtime(self.path)) # If mtime has changed upwards | |
@mtime = mtime # Cache new mtime | |
true # Trigger condition | |
else | |
false # Pass condition | |
end | |
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
#!/bin/sh | |
# | |
# PROVIDE: god | |
# REQUIRE: LOGIN cron | |
# KEYWORD: shutdown | |
# | |
# Add the following line to /etc/rc.conf to enable god: | |
# god_enable (bool): Set to "NO" by default. | |
# Set it to "YES" to enable god. | |
# god_path (str): Path to the god script | |
# god_config (str): Path to the configuration file, "/usr/local/etc/god/master.conf" by default | |
# god_pidfile (str): Path to god pid file, "/var/run/god.pid" by default | |
# god_log (str): Path to god log file, "/var/log/god.log" by default | |
# | |
. /etc/rc.subr | |
name="god" | |
rcvar=`set_rcvar` | |
load_rc_config $name | |
god_enable="${god_enable:-"NO"}" | |
god_path="${god_path:-"/usr/local/bin/god"}" | |
god_config="${god_config:-"/usr/local/etc/god/master.conf"}" | |
god_pidfile="${god_pidfile:-"/var/run/god.pid"}" | |
god_log="${god_log:-"/var/log/god.log"}" | |
command=$god_path | |
command_args="-c $god_config -P $god_pidfile -l $god_log" | |
command_interpreter=`head -n1 $god_path | cut -d'!' -f2` | |
required_files=$god_config | |
pidfile=$god_pidfile | |
stop_cmd="$command terminate" | |
run_rc_command "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment