1

How do I create a PID file for Coldfusion 9?

I'm trying to monitor my Coldfusion 9 server with monit, but it needs a PID file. I see I am supposed to create a 'wrapper' but I am unable to find any information on HOW to create that wrapper.

UPDATE

so these ate the additions I made to the coldfusion init script:

case $ARG in

        start)
                cfstart
                echo `/usr/bin/pgrep -o -f /opt/coldfusion9/runtime/bin/coldfusion9` > /var/run/coldfusion.pid;
        ;;

        stop)
                cfstop
                rm -rf /var/run/coldfusion.pid
        ;;

        restart)
                echo "Restarting ColdFusion 9..."
                cfstop
                rm -rf /var/run/coldfusion.pid

                cfstart
                echo `/usr/bin/pgrep -o -f /opt/coldfusion9/runtime/bin/coldfusion9` > /var/run/coldfusion.pid;
        ;;

and the monit config:

  check process coldfusion with pidfile /var/run/coldfusion.pid
    start program = "/etc/init.d/coldfusion_9 start" with timeout 30 seconds
    stop program  = "/etc/init.d/coldfusion_9 stop" with timeout 30 seconds
    if cpu > 10% for 1 cycles then alert
    if cpu > 80% for 3 cycles then alert
    if cpu > 90% for 10 cycles then alert
    if cpu > 100% for 3 cycles then alert
    if totalmem > 1024.0 MB for 10 cycles then alert
    if loadavg(5min) greater than 10 for 8 cycles then alert
    if 10 restarts within 10 cycles then alert
    group server

[all the alerts are just to keep an eye on it till we know it's working]

It seems to be working, turns up in mmonit, sends alerts on a restart - can anyone see anything wrong with this, or ways to improve?

Sean Kimball
  • 4,506
  • 9
  • 42
  • 73
  • 3
    This [wiki entry on monit](http://mmonit.com/wiki/Monit/FAQ#pidfile) might help. Found it through a quick search. – Leigh Nov 14 '12 at 14:47
  • yes - I saw that, I don't get it at all. Trying to wrap [HA!] my head around this, the PID file is nothing but a file containing the ID of the process, right? Can we not call or include [or something] a script that finds the ID of the server IN the actual init script, writes the pid file and also kills/deletes it on normal shutdown? – Sean Kimball Nov 14 '12 at 15:17
  • Haha, punnage alert ;) Yeah, it does sound like the PID file just contains the ID. But my impression is just based off what I read in the wiki. Maybe confirm it by looking at PID file on your system? If so, barnyr's response links to a thread showing possible ways to get the process id. – Leigh Nov 14 '12 at 15:31
  • well, it is easy enough to get the pid, write & destroy the file in the init script by using a command like echo `/usr/bin/pgrep -o -f /opt/coldfusion9/runtime/bin/coldfusion9` > /var/run/coldfusion.pid; as the last item in the start argument. but if you kill the server outside of the init script, the pid file will still exist. I don't know if this is normal behaviors or not. What monit needs is a 'check command' option like nagios uses! – Sean Kimball Nov 14 '12 at 16:10

1 Answers1

2

If you can't wrap CF's startup in a script to write the PID file, then an alternative may be to use one of the approaches here to get the PID, then invoke it from ColdFusion's onServerStart functionality

Community
  • 1
  • 1
barnyr
  • 5,678
  • 21
  • 28