277 words — 2 minutes read

Daily Log, 2010-11-04

The monit saga from yesterday continued - and was solved. Somewhere deep in the monit documentation, it is stated that monit calls the start and stop programs with a very very minimal environment, and certainly not the full environment that for example the deploy user has.

So the following code will not work: check process some_process with pidfile /path/to/process.pid start "/path/to/executable start" as deploy stop "/path/to/executable stop" as deploy

You can do the following to create an environment for the program: check process some_process with pidfile /path/to/process.pid start "/usr/bin/env PATH=/usr/local/bin HOME=/home/deploy RAILS_ENV=production /path/to/executable start" as deploy stop "/usr/bin/env PATH=/usr/local/bin HOME=/home/deploy RAILS_ENV=production /path/to/executable stop" as deploy

Because this is tedious, it’s probably better to write a small script that sets those values. Here’s one I cooked up:

` #!/bin/sh

export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin export HOME=/home/deploy export RAILS_ENV=production

cd /srv/my_process ./bin/daemon $1 `

Then you can just call this program with either “start” or “stop” as a parameter.

In addition to that, I found a problem with kernel parameters. When we install Postgres 9 on our server, we actually compile it from source. Then we execute the following line in our chef recipe:

execute "sysctl -w kernel.shmmax=#{node[:postgresql9][:shmmax]}"

This works, but does not persist a reboot. It needs to be written to /etc/sysctl.conf too. A quick chef template took care of that…

In other news, my studies have started again, this time with “Object Oriented Design with UML”. This module in my Masters programme a the University of Liverpool seems to have more meat to it, than the last one (Programming the Web), which was a disaster with 6 year old course materials (frames! PHP4! SQL injection!). More reading planned for tonight.

Jens-Christian Fischer

Maker. Musician