I recently moved a long running request in my application to delayed job (the collectiveidea fork) and it went really well. However, after some time the delayed job process died and my users couldn’t use an essential part of the application. I knew it was time for a process monitor. I probably should have put one in to begin with, but I was new to delayed job (really to background processing in general) and the though hadn’t crossed my mind.
I googled around and found several articles that told me exactly how to get bluepill to monitor delayed job and even one for monitoring apache, but none of them seemed to give me a way to create an init script that would ensure that if the server rebooted, bluepill would start up and make sure delayed job continued to work.
It took a while but I finally found this post in the bluepill google group asking about documentation and an init script. The author (Carl) later answered his own post with this gist containing an init script for bluepill! I thought I was set, so I set out to figure out how to create an init script for openSUSE, the flavor of Linux my company uses. A simple google search yielded this great post about creating your own init script in openSUSE.
I followed it’s directions and was very happy to find that issuing the following command /etc/init.d/bluepill restart
resulted in bluepill being started and then executing bluepill status
revealed that the delayed job process was indeed “UP” meaning that bluepill was doing it’s job. Then I rebooted the machine and what happened next isn’t for the faint of heart… after the machine rebooted and I SSH’d back into the box to check the bluepill log and I was devastated. The logs were reporting that bluepill couldn’t start!
1 2 3 |
|
Ok, so maybe it’s not that bad but I’m not a Linux expert (I’m decent, but only because I need to know Linux to host rails) and this was my first init script so I was pretty sunk. Having nowhere else to go, I turned to the author of bluepill himself, Arya. He was very helpful in answering my questions and as it turned out, my environment variables were not setup properly. Well, really the problem was that I had two installations of Ruby (apparently) and so the script was trying to start under the wrong one (I guess). Ayra’s suggestion in the issues section of his github page was to add this code:
1
|
|
It worked and I haven’t bothered to investigate much further. Here is my full init script, hopefully this will help someone else in the future!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|