Never been to DZone Snippets 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

About this user

Sean Santry http://seansantry.com

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

StartupItem for daemontools on OS X

DaemonTools script

#!/bin/sh

. /etc/rc.common

PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin

StartService ()
{
    if [ ! -f /var/run/svscan.pid ]
    then
        ConsoleMessage "Starting svscan"

        # shutdown all the services and their logs (i.e., clean up)
        /usr/local/bin/svc -dx /var/service/* /var/service/*/log

        # launch svscan
        env - PATH=$PATH svscan /var/service > /var/log/svscan.log 2>&1 &
   
        # keep track of svscan's pid
        echo $! > /var/run/svscan.pid
    else
        ConsoleMessage "svscan already running"
    fi
}

StopService()
{
    ConsoleMessage "Stopping svscan and its services"

    # stop svscan
    kill `cat /var/run/svscan.pid`

    # remove the pid file
    rm /var/run/svscan.pid

    # shutdown all the services and their logs (i.e., clean up)
    /usr/local/bin/svc -dx /var/service/* /var/service/*/log
}

RestartService ()
{
    StopService
    StartService
}

RunService "$1"



StartupParameters.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Description</key>
	<string>Daemon tools svscan</string>
	<key>Provides</key>
	<array>
		<string>DaemonTools</string>
	</array>
    <key>Requires</key>
    <array>
        <string>Network Configuration</string>
    </array>
	<key>Uses</key>
	<array>
		<string>Network Configuration</string>
	</array>
	<key>OrderPreference</key>
	<string>Early</string>
</dict>
</plist>

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS