Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

Updated lighttpd control script to kill FCGIs (See related posts)

#!/bin/sh

LIGHTTPD_CONF=/home/USERNAME/etc/lighttpd.conf
PIDFILE=/home/USERNAME/var/run/lighttpd.pid

case "$1" in
    start)
      # Starts the lighttpd deamon
      echo "Starting Lighttpd"
      /usr/local/sbin/lighttpd -f $LIGHTTPD_CONF
    
  ;;
    stop)
      # stops the daemon bt cat'ing the pidfile
      echo "Stopping Lighttpd"
      kill -9 `cat $PIDFILE`
      # kills the dispatch.fcgis
      ps axww | grep dispatch | egrep -v 'grep' | awk '{ print $1 }' | xargs kill -9 
  ;;
    restart)
        ## Stop the service regardless of whether it was
        ## running or not, start it again.
        echo "Restarting Lighttpd"
        $0 stop
        $0 start
  ;;
    reload)
      # reloads the config file by sending HUP
      echo "Reloading config"
      kill -HUP `cat $PIDFILE`
  ;;
    *)
            echo "Usage: lighttpdctl (start|stop|restart|reload)"
            exit 1
        ;;
esac


Comments on this post

rads posts on Nov 17, 2005 at 21:51
Excellent!
eliazar posts on Feb 08, 2006 at 03:10
Great! Thanks for the script! (You actually motivated me to finally sit down and learn some shell scripting.)
eliazar posts on Oct 26, 2006 at 23:57
I'd been using the script without a hitch for some time now but then all of a sudden it won't work if I happen to have an sftp session open (I use WinSCP). The error that appears is "Cannot fork: Resource temporarily unavailable." Is there a way around this?

Thanks!

You need to create an account or log in to post comments to this site.


Related Posts