Fix to create pidfile on Mac

This commit is contained in:
uu59 2014-11-11 12:46:08 +09:00
parent 703eba0079
commit c7233a565e

View File

@ -4,11 +4,11 @@ class Fluentd
module Macosx
def start
detached_command("launchctl load #{plist}")
detached_command("launchctl load #{plist}") && pid_from_launchctl
end
def stop
detached_command("launchctl unload #{plist}")
detached_command("launchctl unload #{plist}") && FileUtils.rm(pid_file)
end
def restart
@ -20,6 +20,13 @@ class Fluentd
def plist
'/Library/LaunchDaemons/td-agent.plist'
end
def pid_from_launchctl
# NOTE: launchctl doesn't make pidfile, so detect pid and store it to pidfile manually
pid = `launchctl list | grep td-agent | cut -f1`.strip
return if pid == ""
File.open(pid_file, "w"){|f| f.write pid }
end
end
end
end