Page 1 of 1

How to install Subsonic on MacOS using LaunchDaemon

PostPosted: Fri Jul 08, 2011 9:04 am
by dandjo
Hi folks,

I struggled with running my Subsonic installation with Apple's LaunchDaemon. LaunchDaemon starts Subsonic as root at system startup. Here's how i did.

Step 1: Download Subsonic standalone version and put contents in "/opt/local/subonic" (be careful with rights: folder and files should have "755 root admin").

Step 2: Edit "/opt/local/subsonic/subsonic.sh" to set the startup variables.
Code: Select all
SUBSONIC_HOME=/opt/local/var/subsonic
SUBSONIC_HOST=0.0.0.0
SUBSONIC_PORT=4040
SUBSONIC_HTTPS_PORT=0
SUBSONIC_CONTEXT_PATH=/
SUBSONIC_MAX_MEMORY=200
SUBSONIC_PIDFILE=
SUBSONIC_DEFAULT_MUSIC_FOLDER=/path/to/music
SUBSONIC_DEFAULT_PODCAST_FOLDER=/path/to/podcasts
SUBSONIC_DEFAULT_PLAYLIST_FOLDER=/path/to/playlists


Step 3: Start Subsonic once with the startup script to ensure that all folders exist: "sh /opt/local/subsonic/subsonic.sh".

Step 4: Create LaunchDaemon ParameterList in "/Library/LaunchDaemons/org.subsonic.plist" with rights "755 root wheel".
Code: Select all
<?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>org.subsonic</string>
        <key>ProgramArguments</key>
                <array>
                        <string>java</string>
                        <string>-Xmx200m</string>
                        <string>-Dsubsonic.home=/opt/local/var/subsonic</string>
                        <string>-Dsubsonic.host=0.0.0.0</string>
                        <string>-Dsubsonic.port=4040</string>
                        <string>-Dsubsonic.httpsPort=0</string>
                        <string>-Dsubsonic.contextPath=/</string>
                        <string>-Dsubsonic.defaultMusicFolder=/path/to/music</string>
                        <string>-Dsubsonic.defaultPodcastFolder=/path/to/podcasts</string>
                        <string>-Dsubsonic.defaultPlaylistFolder=/path/to/playlists</string>
                        <string>-Djava.awt.headless=true</string>
                        <string>-jar</string>
                        <string>subsonic-booter-jar-with-dependencies.jar</string>
                </array>
        <key>WorkingDirectory</key><string>/opt/local/subsonic</string>
        <key>StandardErrorPath</key><string>/opt/local/var/subsonic/subsonic.log</string>
        <key>StandardOutPath</key><string>/opt/local/var/subsonic/subsonic.log</string>
        <key>Debug</key><false/>
        <key>Disabled</key><false/>
        <key>OnDemand</key><false/>
        <key>RunAtLoad</key><true/>
</dict>
</plist>


Step 5: Reboot and check if subsonic started without problems (have a look at "/opt/local/var/subsonic/subsonic.log").

Improvement suggestions are welcome.

Good luck!
dandjo

Re: How to install Subsonic on MacOS using LaunchDaemon

PostPosted: Thu Mar 01, 2012 4:49 pm
by colin
Thanks for this. Works great.

Why?

PostPosted: Fri Apr 27, 2012 7:08 am
by spookybathtub
Why would you want to run Subsonic as root? Sounds like an security risk with no benefit.

Re: How to install Subsonic on MacOS using LaunchDaemon

PostPosted: Fri Apr 27, 2012 7:33 am
by dandjo
Because LaunchDaemon needs root afaik.

Re: How to install Subsonic on MacOS using LaunchDaemon

PostPosted: Fri Apr 27, 2012 3:11 pm
by spookybathtub
Yes, but you could instead make it a LaunchAgent with a normal user. Or simply add Subsonic.app to Login Items in the GUI. I just don't see the benefit of using a LaunchDaemon.

Re: How to install Subsonic on MacOS using LaunchDaemon

PostPosted: Fri Apr 27, 2012 5:01 pm
by dandjo
Placing the App in login items needs a logged in user. With LaunchDeamon Subsonic will start, even if my server crashes and reboots (I disable automatic login by default > security). It is safer to run Subsonic as root than to configure a server to automatically log in on start.

Re: How to install Subsonic on MacOS using LaunchDaemon

PostPosted: Fri Apr 27, 2012 5:42 pm
by bushman4
I'm surprised you can't do both... I'm a windows users, and I can create a service that runs under a non-administrative account for subsonic. Is that not possible on a mac?

Glenn

Re: How to install Subsonic on MacOS using LaunchDaemon

PostPosted: Mon Jan 14, 2013 6:47 pm
by Munger
dandjo wrote:Because LaunchDaemon needs root afaik.


Yes, but you can specify which user you want the daemon to run as:-


UserName <string>
This optional key specifies the user to run the job as. This key is only applicable when launchd is
running as root.

GroupName <string>
This optional key specifies the group to run the job as. This key is only applicable when launchd is
running as root. If UserName is set and GroupName is not, the the group will be set to the default
group of the user.