Forum: Rails deployment init Monit as non-root?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
10a8337cf8879d37affd54e1cab4d79e?d=identicon&s=25 Andy Koch (Guest)
on 2007-07-05 23:35
(Received via mailing list)
Hi All,

Question regarding Monit usage.

I've set up Monit using a config file that is owned by my Rails user.
Which works fine.

However, I'd rest easy on the weekends knowing that if the server is
rebooted then Monit will start up in the init processing and then
start all the Rails business.  Problem is that since my Monit config
file is not owned by root the init process fails to start Monit.  I've
tried some hacking about with the monit init.d script but this seems
rather ungraceful.

Is there a simple way to make this happen?

Or should I just relent and make the config file owned by root?

Thank You all,

Andy K.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2007-07-05 23:41
(Received via mailing list)
Can you make your command be

   su - <Rails user> -c "<monit startup command>"?

That should work in one of the rc3.d (or higher run level) start

10a8337cf8879d37affd54e1cab4d79e?d=identicon&s=25 Andy Koch (Guest)
on 2007-07-05 23:54
(Received via mailing list)
If I'm following you, the idea is to modify the Monit startup script
(namely "/etc/init.d/monit") to use the 'su ....' form.

However, the Monit script uses 'start-stop-daemon' command.  Which has
a chuid option, and that actually works.  But, it hangs on reboot.
While it does start Monit, and faithful employee Monit it turn starts
all it's responsibilities, if one is watching the boot process the
init Monit process never returns.

 ....  At this point I'm wondering if I should get into all the
details ....

ah, what the hell, here is full disclosure...

I modified the monit init script to use chuid option which set user to
my Rails user.  However, it didn't write the Monit state file.  Until
I changed permissions on that folder to allow Rails user.  But then it
wouldn't write the pid file, regardless of any permission changes I
made.  At that point I wondered if I was taking the hard road.

While I'm not opposed to modifying the init script.  My hope was to
find a clean way to run Monit without being (or having access to ) the
root user.

This topic is locked and can not be replied to.