Last active
March 11, 2024 03:56
-
-
Save kozy4324/5552217 to your computer and use it in GitHub Desktop.
Revisions
-
kozy4324 revised this gist
May 10, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -13,8 +13,8 @@ man daemon, agent ------------- - daemon => initdで実行されるようなデーモンプログラム - agent => crondで実行されるような定期実行プログラム plistの置き場所と用途 -
kozy4324 created this gist
May 10, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,96 @@ launchd, launchctl ================== man --- $ man launchd $ man launchctl $ man launchd.plist $ man plutil daemon, agent ------------- - daemon initdで実行されるようなデーモンプログラム - agent crondで実行されるような定期実行プログラム plistの置き場所と用途 --------------------- ~/Library/LaunchAgents Per-user agents provided by the user. /Library/LaunchAgents Per-user agents provided by the administrator. /Library/LaunchDaemons System-wide daemons provided by the administrator. /System/Library/LaunchAgents Per-user agents provided by Mac OS X. /System/Library/LaunchDaemons System-wide daemons provided by Mac OS X. launchctl --------- ### load/unload plistファイルに対して. $ launchctl load /path/to/your.plist ### start/stop plistでload済みのjobはlabelを指定して起動/停止を行う. $ launchctl start label ただ `OnDemand = false`もしくは`KeepAlibe = true`だとloadした時点でjobが稼働するので、stopすると再起動する. ### unload/remove jobを除去する. unloadはplistを指定、removeであればlabelを指定でok. $ launchctl unload /path/to/your.plist $ launchctl remove label ### StandardOutPath, StandardErrorPathを指定しないjobの出力先 謎. launchctl.plist --------------- ### 標準出力/エラーの出力先 StandardOutPath, StandardErrorPathにファイルパスを設定する. ### plistで設定するOnDemaondとKeepAlive OnDemandは10.5以降でdeprecatedだからKeepAliveを使うべき、true/false以外に以下でjob継続するかが設定できる. 1. 前回のexit code 2. ネットワーク状況 3. 特定ファイルの有無 4. 他jobの有無 mongodをlaunchctlでdaemon化 --------------------------- ### my.mongod.plist ``` <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd > <plist version="1.0"> <dict> <key>Label</key> <string>my.mongod</string> <key>Program</key> <string>/path/to/mongod</string> <key>KeepAlive</key> <true/> </dict> </plist> ``` /Library/LaunchDaemons以下にぶちこめば次回システム起動時に読み込まれる.