How do I get Glassfish to automatically start on Mac OS X

In this forum thread, Leonard Sitongia kindly posted:

Here's my StartupItems configuration. 

Users/sitongia$ ls -lR /Library/StartupItems/SJSAS/
total 16
drwxr-xr-x 3 root wheel 102 Jul 28 2004 Resources
-rwxr-xr-x 1 root wheel 673 Oct 25 07:30 SJSAS
-rw-r--r-- 1 root wheel 250 Oct 25 07:27 StartupParameters.plist

/Library/StartupItems/SJSAS/Resources:
total 0
drwxr-xr-x 3 root wheel 102 Oct 25 07:28 English.lproj

/Library/StartupItems/SJSAS/Resources/English.lproj:
total 8
-rw-r--r-- 1 root wheel 247 Oct 25 07:28 Localizable.strings

/Users/sitongia$ cat
/Library/StartupItems/SJSAS/Resources/English.lproj/Localizable.strings
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM
"file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>Starting Glassfish</key>
<string>Starting Glassfish</string>
</dict>
</plist>

/Users/sitongia$ cat /Library/StartupItems/SJSAS/StartupParameters.plist
{
Description = "Glassfish";
Provides = ("Servlet Engine");
Requires = ("DirectoryServices");
OrderPreference = "None";
Messages =
{
start = "Starting Glassfish";
stop = "Stopping Glassfish";
};
}

/Users/sitongia$ cat /Library/StartupItems/SJSAS/SJSAS
#!/bin/sh

. /etc/rc.common

export JAVA_HOME=/Library/Java/Home
#export JAVA_OPTS="-server -Xms128m -Xmx128m"
export GLASSFISH_HOME=/usr/local/glassfish-v2

##
# Start the Glassfish Glassfish
##

StartService ()
{
if [ "${SJSAS:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Starting Glassfish"
$GLASSFISH_HOME/bin/asadmin start-domain domain1
fi
}

StopService ()
{
ConsoleMessage "Stopping Glassfish"
$GLASSFISH_HOME/bin/asadmin stop-domain domain1
}

RestartService ()
{
if [ "${SJSAS:=-NO-}" = "-YES-" ]; then
ConsoleMessage "Reloading Glassfish"
StopService
StartService
else
StopService
fi
}

RunService "$1"

/Users/sitongia$ fgrep SJSAS /etc/hostconfig SJSAS=-YES-

I think that's it.

Issue-Tracker Issue to track this

IT: 4243


I recently get this idea fro your last post It is fantastic though I was looking for it to do.

Construction liability insurance

Posted by james1122 at Jul 18, 2011 08:17