Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've created the file /System/Library/LaunchDaemons/com.rundeckd.plist with this content:

<?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>
    <true/>
    <key>Label</key>
    <string>com.rundeckd</string>
    <key>ProgramArguments</key>
    <array>
        <string>/test/rundeck/server/sbin/rundeckd</string>
        <string>start</string>
    </array>
    <key>KeepAlive</key>
    <true/>

    <key>StandardOutPath</key>
    <string>/test/rundeck/var/log/launchd_out.log</string>
    <key>StandardErrorPath</key>
    <string>/test/rundeck/var/log/launchd_sdd.log</string>
    <key>Debug</key>
    <true/>
</dict>
</plist>

However, sudo launchctl list does not show this rundeckd.

why?

also, rundeckd does not run it at boot time, nor the log files are never created. (note, i've modified rundeckd to have the required $RDECK_BASE env variable hard-coded in the script)

Update

Gordon Davisson, I've modified the plist as you said, and without modifying the rundeckd script, I get the following:

nohup: can't detach from console: Inappropriate ioctl for device

then, I have tried adding the option "launchd" to rundeckd (currently, there was start, stop and status), as follows:

launchd() {
    echo "%s" "launchd $prog: "
    touch $LOK_FILE
    $rundeckd 2>&1 >>$RDECK_BASE/var/log/service.log &
    PID=$!
    echo $PID > $PID_FILE
    fg $PID  # block until it is stopped
}

but I get the error fg: no job control, as it seems that I cannot run "fg" because it is not an interactive shell. http://stackoverflow.com/questions/11821378/what-does-bashno-job-control-in-this-shell-mean

share|improve this question
    
add comment

2 Answers

Your launchd plist marks the item as disabled:

    <key>Disabled</key>
    <true/>

In order to get it to run, you need to either change that to <false/>, or override it with sudo launchctl load -w /System/Library/LaunchDaemons/com.rundeckd.plist (the -w makes it do a permanent override).

Also, have you modified the script to avoid daemonizing itself? If not, you'll need to change <key>KeepAlive</key> to <false/>, and add <key>AbandonProcessGroup</key><true/>.

BTW, you can also define environment variables in the .plist instead of having to modify the script to include them:

    <key>EnvironmentVariables</key>
    <dict>
        <key>RDECK_BASE</key>
        <string>/Users/david/bin/rundeck</string>
    </dict>

And finally, I'd recommend changing the Label & filename -- they're supposed to be based on a reverse DNS naming convention, so unless you own the rundeckd.com domain, you shouldn't be using that as a label or label prefix. For homemade entries like this, I recommend using the "local" prefix, i.e. "local.rundeckd".

Update: job control is only available in interactive shells; use wait $PID instead of fg $PID.

share|improve this answer
    
thanks for the info; I've updated the question with your info. –  David Portabella May 28 '13 at 8:19
add comment
up vote 0 down vote accepted

https://gist.github.com/dportabella/7714449

$RDECK_BASE/server/sbin/rundeck_launchd is a script to launch rundeck without sending the process into the background (required by OSX Launchd).

/System/Library/LaunchAgents/david.rundeck.plist is a configuration file to set-up rundeck as a Mac OSX launchd service. You need to modify this file according to your needs. in this example, RDECK_BASE is /Users/david/bin/rundeck.

after installing these two files, reboot your computer, and rundeck will be started at boot time.

you can then stop, start and see the status of the rundeck service:

$ launchctl start david.rundeck
$ launchctl stop david.rundeck
$ launchctl list david.rundeck

(this script is based on $RDECK_BASE/server/sbin/rundeckd script)

File $RDECK_BASE/server/sbin/rundeck_launchd

#!/bin/bash 
#
# rundeck_launchd    Startup script for the RunDeck Launcher install
#   paramaters:
#     - env vars: [RDECK_BASE, RDECK_PORT, RDECK_LAUNCHER]
#     - standard RDECK_PORT values: [http: 4440, https: 4443]

export RDECK_BASE=${0%/*/*/*}

# RDECK_BASE must be set and exist
[ -z "$RDECK_BASE" -o ! -d "$RDECK_BASE" ] && {
    echo "RDECK_BASE not set or does not exist" ;
    exit 1 ;
}

# Source installation profile
. $RDECK_BASE/etc/profile

# Get the Launcher Jar path
[ -z "$RDECK_LAUNCHER" ] && {
    # Defaults to location of first startup
    RDECK_LAUNCHER=$(ls $RDECK_BASE/rundeck-launcher-*.jar)
}
[ -r "$RDECK_LAUNCHER" ] || {
    echo "RDECK_LAUNCHER not found: $RDECK_LAUNCHER" 
    exit 1;
}

# lookup the server port from the tools config file
RDECK_PORT=`awk '/framework.server.port/ {print $3}' $RDECK_BASE/etc/framework.properties`

# set the ssl opts if https is configured
SSL_OPTS=
proto=$(awk '/framework.server.url = / {split($3, a, ":"); print a[1]}' $RDECK_BASE/etc/framework.properties)
[ "${proto:-http}" == "https" ] && {
   SSL_OPTS="-Drundeck.ssl.config=$RDECK_BASE/server/config/ssl.properties"
}

rundeckd="${JAVA_HOME}/bin/java ${RDECK_JVM} -Dserver.http.port=${RDECK_PORT:=4440} $SSL_OPTS -jar ${RDECK_LAUNCHER}"

[ -w $RDECK_BASE/var ] || {
    echo "RDECK_BASE dir not writable: $RDECK_BASE" 
    exit 1 ;
}

mkdir -p $RDECK_BASE/var/run
mkdir -p $RDECK_BASE/var/log
mkdir -p $RDECK_BASE/var/lock/subsys

$rundeckd 2>&1 >>$RDECK_BASE/var/log/service.log

File /System/Library/LaunchAgents/david.rundeck.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>Label</key>
    <string>david.rundeck</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/david/bin/rundeck/server/sbin/rundeck_launchd</string>
    </array>
    <key>KeepAlive</key>
    <true/>
    <key>RunAtLoad</key>
    <true/>
    <key>UserName</key>
    <string>david</string>
    <key>Debug</key>
    <true/>
</dict>
</plist>
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.