Project

General

Profile

Autostart Core on Mac

Introduction

One common method by which to start a daemon on the Mac, either in realtime or at boot, is to use launchd. Using this method requires the creation of a property list file (plist) which is used by launchd to start the desired daemon which is, in this particular scenario, the quasselcore daemon. Also, while our primary goal is to have the daemon launch at boot, much of the following also applies to manually using launchd (via the launchctl command) to run & stop the same daemon via the command line in realtime.

NOTE: The terms "launch controller" or "controller" are used as shorthand in reference to using the launchctl command.


Creating & saving the plist file

First, we need to create the necessary plist file which will then be saved to the user's launch agent directory - examples and location are provided below (if the file exists in the proper location, you may skip this step):

plist example (by e-jat)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.quasselcore.daemon</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Applications/Quassel/quasselcore</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>WorkingDirectory</key>
    <string>/Applications/Quassel</string>
</dict>
</plist>

plist save location

FILENAME: org.quassel-irg.quasselcore.plist
DIRECTORY: ~/Library/LaunchAgents/
FULL FILENAME: ~/Library/LaunchAgents/org.quassel-irg.quasselcore.plist


Manually loading & unloading using the launch controller

NOTE: The following commands must be executed by the user who owns the plist-file. In addition, do not use sudo when using launchctl with user-owned plist LaunchAgent files. Trying to execute these commands as a user who does not own the plist or with sudo will result in the system detecting an ownership anomaly and refusal to launch the quasselcore daemon.

Load:

launchctl load ~/Library/LaunchAgents/org.quassel-irg.quasselcore.plist

Unload:

launchctl unload ~/Library/LaunchAgents/org.quassel-irg.quasselcore.plist

Configuring runtime options

Several runtime options exist to enhance and modify quasselcore's operation (see list below). These options apply to both daemon launch methods: (a) via the controller (i.e. launchd); or (b) via the command line. When launching the daemon via the controller, all options are specified in the same plist file created above. Each option is specified by the use of <string> statements in the ProgramArguments array section of the plist. When entering the different options, no white-space or other parsing is entered - the controller will take care of those specifics. Syntax and examples follow:

plist option argument syntax

<string>OPTION_ARGUMENT</string>

EXAMPLE 1: listen on non-default port

<string>-p 12345</string>

EXAMPLE 2: enable logging to syslog

<string>--syslog</string>

EXAMPLE 3: enable debug mode

<string>-d</string>

OR

<string>--debug</string>

EXAMPLE 4: all of the above along with the ProgramArguments section header

<key>ProgramArguments</key>
<array>
    <string>/Applications/Quassel/quasselcore</string>
    <string>-p 12345</string>
    <string>--syslog</string>
    <string>-d</string>
</array>

Runtime option list

--debug, -d                             Enable debug output

--help, -h                              Display this help and exit

--version, -v                           Display version information

--configdir, -c <path>                  Specify the directory holding
                                        configuration files, the SQlite
                                        database and the SSL certificate
                                        --configdir instead

--listen <<address>[,<address>[,...]]>  The address(es) quasselcore will
                                        listen on

--port, -p <port>                       The port quasselcore will listen at

--norestore, -n                         Don't restore last core's state

--loglevel, -L <level>                  Loglevel Debug|Info|Warning|Error

--syslog                                Log to syslog

--logfile, -l <path>                    Log to a file

--select-backend <backendidentifier>    Switch storage backend (migrating
                                        data if possible)

--add-user                              Starts an interactive session to add
                                        a new core user

--change-userpass <username>            Starts an interactive session to
                                        change the password of the user
                                        identified by <username>

--oidentd                               Enable oidentd integration

--oidentd-conffile <file>               Set path to oidentd configuration
                                        file

--require-ssl                           Require SSL for remote (non-loopback)
                                        client connections

--ssl-cert <path>                       Specify the path to the SSL
                                        Certificate

--ssl-key <path>                        Specify the path to the SSL key

--enable-experimental-dcc               Enable highly experimental and
                                        unfinished support for CTCP DCC
                                        (DANGEROUS)