Skip to content

Running Trunk Recorder

tadscottsmith edited this page Aug 15, 2022 · 8 revisions

Running trunk recorder.

If all goes well you should now have the executable named trunk-recorder, and created the config.json configuration file as described in the Wiki and README.

From your build directory (e.g. trunk-build) you can now run ./trunk-recorder

Runtime options

Trunk Recorder will look for a config.json file in the same directory as it is being run in. You can point it to a different config file by using the --config argument on the command line, for example: ./trunk-recorder --config=examples/config-wmata-rtl.json.

Auto start as service

https://github.com/robotastic/trunk-recorder/blob/70698818065b24a494fc5488c82445609eab9ebc/examples/SETUP_SERVICE.md

Running as a Service on MacOS

Switch to the LaunchDaemons folder.

cd /Library/LaunchDaemons

Create a new plist file to define the service.

sudo vi trunk-recorder.plist

Modify the sample .plist file below to meet your environment. You'll need to modify the Program, WorkingDirectory, EnvironmentVariables, UserName, and GroupName at a minimum. Make sure that your PATH includes the directory(s) where sox and fdkaac are installed. You can use the command which sox fdkaac to find their locations.

<?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>trunk-recorder</string>

    <key>Program</key>
    <string>/Users/radio/trunk-build/trunk-recorder</string>
    <key>WorkingDirectory</key>
    <string>/Users/radio/trunk-build/</string>

    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/opt/local/bin/</string>
    </dict>

    <key>UserName</key>
    <string>radio</string>
    <key>GroupName</key>
    <string>staff</string>
    <key>InitGroups</key>
    <true/>

    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>StandardErrorPath</key>
    <string>/Users/radio/trunk-build/trunk-recorder-service.log</string>
</dict>
</plist>

Ensure the .plist file ownership is set to root:wheel. If you used another editor to create or modify the .plist, or if it is copied from another location on the system, the service may not start unless file ownership has been set correctly. Use ls -al trunk-recorder.plist to ensure the ownership looks similar to below:

-rw-r--r--  1 root  wheel  856 Aug 12 11:55 trunk-recorder.plist

If the file does not have the correct permissions, reset root ownership with the following command:

sudo chown root:wheel trunk-recorder.plist

Load the service using the following command:

sudo launchctl load trunk-recorder.plist

Verify that the service is running using one of the following two commands:

sudo launchctl list | grep trunk-recorder
ps -ef | grep trunk-recorder

To restart, or temporary stop and start the service, use the following commands:

sudo launchctl stop trunk-recorder.plist
sudo launchctl start trunk-recorder.plist

To permanently unload the service using the following command:

sudo launchctl unload trunk-recorder.plist