Skip to content

Instantly share code, notes, and snippets.

@frootis
Forked from mystix/launchd_wrapper.sh
Created February 6, 2014 20:11
Show Gist options
  • Save frootis/8851683 to your computer and use it in GitHub Desktop.
Save frootis/8851683 to your computer and use it in GitHub Desktop.

Revisions

  1. @mystix mystix revised this gist Aug 19, 2011. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions org.apache.tomcat.plist
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?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"><!-- NOTE: place this file in /Library/LaunchDaemons, and update the username appropriately -->
    <plist version="1.0"><!-- NOTE: place this file in /Library/LaunchDaemons -->
    <dict>
    <key>Label</key>
    <string>org.apache.tomcat</string>
    @@ -26,6 +26,6 @@
    <key>StandardOutPath</key>
    <string>/Users/username/tomcat/logs/launchd.stdout</string>
    <key>UserName</key>
    <string>marc</string>
    <string>root</string><!-- MUST be root in order to run tomcat on port 80 -->
    </dict>
    </plist>
  2. @mystix mystix revised this gist Aug 19, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion org.apache.tomcat.plist
    Original file line number Diff line number Diff line change
    @@ -26,6 +26,6 @@
    <key>StandardOutPath</key>
    <string>/Users/username/tomcat/logs/launchd.stdout</string>
    <key>UserName</key>
    <string>nobody</string>
    <string>marc</string>
    </dict>
    </plist>
  3. @mystix mystix revised this gist Aug 19, 2011. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -17,8 +17,7 @@ export CATALINA_PID=/tmp/$$
    # Uncomment to increase Tomcat's maximum heap allocation
    # export JAVA_OPTS=-Xmx512M $JAVA_OPTS

    # start tomcat in a more secure manner on OSX -- see http://www.mulesoft.com/tomcat-start
    cd /; sudo -u nobody . $CATALINA_HOME/bin/catalina.sh start; cd -
    . $CATALINA_HOME/bin/catalina.sh start

    # Allow any signal which would kill a process to stop Tomcat
    trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
  4. @mystix mystix revised this gist Aug 19, 2011. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ export CATALINA_PID=/tmp/$$
    # export JAVA_OPTS=-Xmx512M $JAVA_OPTS

    # start tomcat in a more secure manner on OSX -- see http://www.mulesoft.com/tomcat-start
    cd /; . $CATALINA_HOME/bin/catalina.sh start; cd -
    cd /; sudo -u nobody . $CATALINA_HOME/bin/catalina.sh start; cd -

    # Allow any signal which would kill a process to stop Tomcat
    trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
    2 changes: 1 addition & 1 deletion org.apache.tomcat.plist
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?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"><!-- NOTE: place this file in /Library/LaunchDaemons -->
    <plist version="1.0"><!-- NOTE: place this file in /Library/LaunchDaemons, and update the username appropriately -->
    <dict>
    <key>Label</key>
    <string>org.apache.tomcat</string>
  5. @mystix mystix revised this gist Aug 19, 2011. 1 changed file with 6 additions and 8 deletions.
    14 changes: 6 additions & 8 deletions org.apache.tomcat.plist
    Original file line number Diff line number Diff line change
    @@ -2,32 +2,30 @@
    <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0"><!-- NOTE: place this file in /Library/LaunchDaemons -->
    <dict>
    <key>Disabled</key>
    <key>Label</key>
    <string>org.apache.tomcat</string>
    <key>OnDemand</key>
    <false/>
    <key>RunAtLoad</key>
    <true/>
    <key>EnvironmentVariables</key>
    <dict>
    <key>CATALINA_HOME</key>
    <string>/Users/username/tomcat</string>
    <key>JAVA_HOME</key>
    <string>/Library/Java/Home</string>
    </dict>
    <key>Label</key>
    <string>org.apache.tomcat</string>
    <key>OnDemand</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
    <string>/Users/username/tomcat/bin/launchd_wrapper.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceDescription</key>
    <string>Tomcat</string>
    <key>StandardErrorPath</key>
    <string>/Users/username/tomcat/logs/launchd.stderr</string>
    <key>StandardOutPath</key>
    <string>/Users/username/tomcat/logs/launchd.stdout</string>
    <key>UserName</key>
    <string>root</string>
    <string>nobody</string>
    </dict>
    </plist>
  6. @mystix mystix revised this gist Aug 19, 2011. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -17,6 +17,7 @@ export CATALINA_PID=/tmp/$$
    # Uncomment to increase Tomcat's maximum heap allocation
    # export JAVA_OPTS=-Xmx512M $JAVA_OPTS

    # start tomcat in a more secure manner on OSX -- see http://www.mulesoft.com/tomcat-start
    cd /; . $CATALINA_HOME/bin/catalina.sh start; cd -

    # Allow any signal which would kill a process to stop Tomcat
  7. @mystix mystix revised this gist Aug 19, 2011. 2 changed files with 7 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -17,7 +17,7 @@ export CATALINA_PID=/tmp/$$
    # Uncomment to increase Tomcat's maximum heap allocation
    # export JAVA_OPTS=-Xmx512M $JAVA_OPTS

    . $CATALINA_HOME/bin/catalina.sh start
    cd /; . $CATALINA_HOME/bin/catalina.sh start; cd -

    # Allow any signal which would kill a process to stop Tomcat
    trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP
    8 changes: 6 additions & 2 deletions tomcat
    Original file line number Diff line number Diff line change
    @@ -10,6 +10,10 @@ elif [ 'stop' = "$1" ]; then
    COMMAND=unload
    fi

    if [ -n "$COMMAND" ]; then
    if [ 'restart' = "$1" ]; then
    echo Restarting tomcat service...
    sudo launchctl unload -w /Library/LaunchDaemons/org.apache.tomcat.plist
    sudo launchctl load -w /Library/LaunchDaemons/org.apache.tomcat.plist
    elif [ -n "$COMMAND" ]; then
    sudo launchctl $COMMAND -w /Library/LaunchDaemons/org.apache.tomcat.plist
    fi
    fi
  8. @mystix mystix revised this gist Nov 10, 2010. 2 changed files with 5 additions and 5 deletions.
    2 changes: 1 addition & 1 deletion launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    # NOTE: this is an OSX launchd wrapper shell script for Tomcat (to be placed in $CATALINA_HOME/bin)

    CATALINA_HOME=/Users/username/apache-tomcat-6.0.29
    CATALINA_HOME=/Users/username/tomcat

    function shutdown() {
    date
    8 changes: 4 additions & 4 deletions tomcat.plist → org.apache.tomcat.plist
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    <key>EnvironmentVariables</key>
    <dict>
    <key>CATALINA_HOME</key>
    <string>/Users/username/apache-tomcat-6.0.29</string>
    <string>/Users/username/tomcat</string>
    <key>JAVA_HOME</key>
    <string>/Library/Java/Home</string>
    </dict>
    @@ -17,16 +17,16 @@
    <false/>
    <key>ProgramArguments</key>
    <array>
    <string>/Users/username/apache-tomcat-6.0.29/bin/launchd_wrapper.sh</string>
    <string>/Users/username/tomcat/bin/launchd_wrapper.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceDescription</key>
    <string>Tomcat</string>
    <key>StandardErrorPath</key>
    <string>/Users/username/apache-tomcat-6.0.29/logs/launchd.stderr</string>
    <string>/Users/username/tomcat/logs/launchd.stderr</string>
    <key>StandardOutPath</key>
    <string>/Users/username/apache-tomcat-6.0.29/logs/launchd.stdout</string>
    <string>/Users/username/tomcat/logs/launchd.stdout</string>
    <key>UserName</key>
    <string>root</string>
    </dict>
  9. @mystix mystix revised this gist Nov 9, 2010. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions tomcat
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    #!/bin/bash

    # convenience script for easily starting/stopping tomcat on OSX
    # (to be placed in /usr/local/bin. remember to run chmod +x on it)
    if [ 'start' = "$1" ]; then
    echo Starting tomcat service...
    COMMAND=load
    elif [ 'stop' = "$1" ]; then
    echo Stopping tomcat service...
    COMMAND=unload
    fi

    if [ -n "$COMMAND" ]; then
    sudo launchctl $COMMAND -w /Library/LaunchDaemons/org.apache.tomcat.plist
    fi
  10. @mystix mystix revised this gist Nov 3, 2010. 2 changed files with 3 additions and 1 deletion.
    2 changes: 2 additions & 0 deletions launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    #!/bin/bash

    # NOTE: this is an OSX launchd wrapper shell script for Tomcat (to be placed in $CATALINA_HOME/bin)

    CATALINA_HOME=/Users/username/apache-tomcat-6.0.29

    function shutdown() {
    2 changes: 1 addition & 1 deletion tomcat.plist
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    <?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">
    <plist version="1.0"><!-- NOTE: place this file in /Library/LaunchDaemons -->
    <dict>
    <key>Disabled</key>
    <false/>
  11. @mystix mystix revised this gist Nov 3, 2010. 2 changed files with 34 additions and 1 deletion.
    2 changes: 1 addition & 1 deletion launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #!/bin/bash

    CATALINA_HOME=~/apache-tomcat-6.0.29
    CATALINA_HOME=/Users/username/apache-tomcat-6.0.29

    function shutdown() {
    date
    33 changes: 33 additions & 0 deletions tomcat.plist
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    <?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>Disabled</key>
    <false/>
    <key>EnvironmentVariables</key>
    <dict>
    <key>CATALINA_HOME</key>
    <string>/Users/username/apache-tomcat-6.0.29</string>
    <key>JAVA_HOME</key>
    <string>/Library/Java/Home</string>
    </dict>
    <key>Label</key>
    <string>org.apache.tomcat</string>
    <key>OnDemand</key>
    <false/>
    <key>ProgramArguments</key>
    <array>
    <string>/Users/username/apache-tomcat-6.0.29/bin/launchd_wrapper.sh</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceDescription</key>
    <string>Tomcat</string>
    <key>StandardErrorPath</key>
    <string>/Users/username/apache-tomcat-6.0.29/logs/launchd.stderr</string>
    <key>StandardOutPath</key>
    <string>/Users/username/apache-tomcat-6.0.29/logs/launchd.stdout</string>
    <key>UserName</key>
    <string>root</string>
    </dict>
    </plist>
  12. @mystix mystix created this gist Nov 3, 2010.
    24 changes: 24 additions & 0 deletions launchd_wrapper.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/bash

    CATALINA_HOME=~/apache-tomcat-6.0.29

    function shutdown() {
    date
    echo "Shutting down Tomcat"
    $CATALINA_HOME/bin/catalina.sh stop
    }

    date
    echo "Starting Tomcat"
    export CATALINA_PID=/tmp/$$

    # Uncomment to increase Tomcat's maximum heap allocation
    # export JAVA_OPTS=-Xmx512M $JAVA_OPTS

    . $CATALINA_HOME/bin/catalina.sh start

    # Allow any signal which would kill a process to stop Tomcat
    trap shutdown HUP INT QUIT ABRT KILL ALRM TERM TSTP

    echo "Waiting for `cat $CATALINA_PID`"
    wait `cat $CATALINA_PID`