Please note that this is something I do when I try to track down a certain bug, and not something I recommend in your production environment.
I've created my own little script that installs the wrapper script:
#! /bin/ksh cat > /opt/membase/bin/launcher.sh <#! /bin/ksh logfile=/tmp/membase.log binary=\`basename \$0\` echo pid \$\$ : \$0 \$* >> \${logfile} exec \${0}.bin "\$@" 2>&1 | awk "{printf(\"%d: %s\n\", $$, \\\$0); }" >> \${logfile} EOF chmod a+x /opt/membase/bin/launcher.sh for f in memcached vbucketmigrator moxi do mv /opt/membase/bin/${f}/${f} /opt/membase/bin/${f}/${f}.bin ln -s ../launcher.sh /opt/membase/bin/${f}/${f} done
As an extra bonus this redirects all of the output from the processes to
/tmp/membase.log
, so that I can just check there for the error text instead of running browse_logs and start decoding the output there.The above script use the same wrapper script for all processes, but sometimes I want to add extra options to one of the processes (like enabling verbosity for
vbucketmigrator
). All I need to do is just to replace the link with a copy of the file:root@ubuntu:/opt/membase/bin# rm vbucketmigrator/vbucketmigrator root@ubuntu:/opt/membase/bin# cp -p launcher.sh vbucketmigrator/vbucketmigrator
and edit the file. Since I'm going to add extra command line options, I'm most likely expecting more output so normally I store the output in its own file as well:
#! /bin/ksh logfile=/tmp/vbucketmigrator.$$
binary=`basename $0` echo pid $$ : $0 $* >> ${logfile} exec ${0}.bin "$@" -vv 2>&1 >> ${logfile}
The next time
vbucketmigrator
starts it will dump the message traffic to /tmp/vbucketmigrator.pid
No comments:
Post a Comment