LoginSignup
2
2

More than 5 years have passed since last update.

bot をローカルのMacに常駐させた。

Last updated at Posted at 2016-03-02

direct 向けに前回作った bot (daab) は、個人的で実験的なもので、業務時間にローカルの Mac で動いてくれたら十分なので、Mac に常駐させることにした。

LaunchAgents で動かすことにしたので、
~/Library/LaunchAgents/mybot.plist を追加

mybot.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>mybot</string>
  <key>ProgramArguments</key>
  <array>
      <string>/usr/local/bin/daab</string>
      <string>run</string>
  </array>
  <key>RunAtLoad</key>
  <true/>
  <key>WorkingDirectory</key>
  <string>/Users/some-user/some-dir/mybot</string>
  <key>EnvironmentVariables</key>
  <dict>
    <key>PATH</key>
    <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string>
  </dict>
</dict>
</plist>

各プロパティの意味は、次のページを参照
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man5/launchd.plist.5.html

デバッグログ出力のためにログレベルを変更すべく
/Users/some-user/some-dir/mybot/.env に次の行を追加

.env
HUBOT_LOG_LEVEL=debug

起動・終了を確認するために、ログファイルを tail -f しながら…

$ tail -f /Users/some-user/some-dir/mybot/hubot.log

起動を確認

$ launchctl load ~/Library/LaunchAgents/mybot.plist

終了を確認

$ launchctl unload ~/Library/LaunchAgents/mybot.plist

いずれも、それらしいログがでていることを確認

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2