koukiblog

たぶんweb系の話題

pm2でhubotを起動するとき

pm2でhubotを起動する場合、

 pm2 start -f bin/hubot -x --name botname -- -a adapter

のように紹介されている記事が多かったのだけど、bin/hubotがJavascriptとして解釈されてしまいうまくいかない。

 pm2 start -f bin/hubot.sh -x --name botname -- -a adapter

としてみると、無事起動。

拡張子で判断しているみたいだったので、ソースを見てみるとそれっぽい記述を見つけたのでたぶんそうなんだと思う

https://github.com/Unitech/pm2/blob/1c3fcb83b65e430a5734d576610d27cc7a0bf4fd/lib/Common.js#L355

  var noInterpreter     = (!app.exec_interpreter || 'none' == app.exec_interpreter),
      extName           = path.extname(app.pm_exec_path),
      betterInterpreter = extItps[extName];

のextItpsはintpreter.jsonで定義されていて以下のような内容になっている
https://github.com/Unitech/pm2/blob/3f5641a67d13b746b861dd2a491206df2eb50cca/lib/API/interpreter.json

拡張子がshだとbashで解釈される。何もないとnodeになる様子。