如何在monit中设置用户谁运行命令尊重他的.bash_profile?

我想监督我的Rails应用程序与monit独angular兽运行。

以root用户身份login后,从shell运行下列两行将会失败:

  • "/srv/app/current/config/unicorn.sh start"
  • su -c "/srv/app/current/config/unicorn.sh start" app

什么工作是:

  • su -c "/srv/app/current/config/unicorn.sh start" - app

它并不让我惊讶,我使用rbenv ,它需要在$PATH进行一些修改,我在.bash_profile做了一些修改。 不幸的是,我不能让它与monit一起工作。 我准备了一些基于我在互联网上发现的脚本:

 check process unicorn with pidfile /srv/app/shared/pids/unicorn.pid start program = "/srv/app/current/config/unicorn.sh start" as uid app and gid app stop program = "/srv/app/current/config/unicorn.sh stop" as uid app and gid app group www 

它看起来像.bash_profile不读在这种情况下 – 如何改变它? 或者,或者,如何添加几个目录到monit使用的$PATH

谢谢你的帮助。

我刚刚发现,最好的办法是将这个unicorn.sh与shebang指向/bin/bash并在脚本的开头设置$PATH