One question I sometimes forget to ask myself, when I’m coming up with solutions to problems is this: “Is it simple enough?” Even though I try and make a habit of asking myself that often I, sometimes, don’t ask often enough. The lesson of the importance of simplicity in both software development and systems management is one of those lessons that you really only ever “learn” after you’re war scarred and battle weary. One day it clicks, and you realize “hey… this should be easier.”
The interesting thing about the problems that we (as a community of tech minded developer types, and systems people) is that the majority of our solutions can be done easily. Sure there’s always something… at the deep dark core of a really difficult problem… that will always be that arcane black magic voodoo bit of code. But by and large everything else can (and should) be simple.
I wonder what stories you, my 2.5 readers, may have to share on the subject. When was it that you became totally fed up with writing complex solutions? Or have you some other opinion on the matter?
Andy bogged a piece of advice that I have him which I got from Barry… and if you want to know how to get the true absolute path to the real location of the current script is from inside of it (like phps realpath and __FILE__) I suggest you check it out
I’ve written a little something which is gaining some traction internally, and I always intended to share it with the world. So… Here. daemon-functions.sh
What it does is allow you to write a bash function called “payload” like so:
function payload() {
while [ true ]; do
checkforterm
date
sleep 1
done
}
source path/to/daemon-functions.sh
Once you’ve done that it all just happens. daemon-functions gives you logging of stderr, stdout, a pid file, start, stop, pause, resume, and more functions. when you start your daemon it detaches completely from your terminal and runs in the background. Works very simply with monit straight out of the box. you can have as many daemons as you wish in the same directory and they wont clobber each other (as the pid, control, and log files all are dynamically keyed off of the original script name.) Furthermore inside your execution loop inside of the payload function place a checkforterm call at any place which it makes sense for your script to be paused, or stopped. it can detect stale pid files and run anyway if the process isnt really running. As an added bonus you dont actually have to loop inside payload, you can put any thing in there, have a script thats not a daemon, but will take an hour, day, week, month to finish? stick it in, run it, and forget it.
has any body else noticed a huge increase in AIM spam lately?
I’m just waiting for the akismet-style service/plugin combo to come along for the IM space… It’s probably long overdue.