Hi folks -
I'm trying to get ferret under the control of monit. I start monit
from an init script, so it starts with root privileges. I need it to
run my ferret server as user "tm". The consensus on the web is that
this is the way to do that:
check process ferret with pidfile /var/www/tm/current/log/ferret.pid
start program = "/bin/su -c 'cd /www/application/current/ &&
script/ferret_server start -e production' tm"
stop program = "/bin/su -c 'cd /www/application/current/ &&
script/ferret_server stop -e production' tm"
When I try that, I get this output:
Starting monit: 'ferret' process is not running
'ferret' trying to restart
'ferret' start: /bin/su
'ferret' failed to start
That works from root's command line, but will not work with monit, and
I don't know why. I tried all manner of backslash-escaping the quotes,
to no avail. So I discovered that you can pass "uid" and "gid"
arguments to a start option, and I switched to this (I'll just show
the start line for brevity):
start program = "cd /var/www/tm/current/ && script/ferret_server
-e production start"
as uid tm and gid tm
That errors out complaining that there's no such command as "cd"
(which is true, it's a shell command, not a binary). If I don't change
to the right working directory, ferret refuses to start because it
can't create "log/ferret.pid" (and there's no way I know of to give it
a full path to where it should put its log file).
Surely there has to be a way to do this. Can I get monit to change its
working directory as part of a start directive? Is there some other
way around all this?