[Tutorial] Complete Tutorial on Installing libresonic/subsonic Standalone on Raspberry Pi

Why Choose Libresonic over Subsonic?

libresonic is essentially subsonic but with the license feature removed. Subsonic allows mobile streaming for 30 days whereas it is disabled unless you donate.

The main reason as to why I decided to deploy libresonic as Standalone rather than a tomcat WAR (Web Archive) package is because tomcat8 will hang when deploying libresonic.war package for somewhat unknown reason, so I resorted to compile a debian package manually using the following method.

Prerequisites

Download the following packages using debian apt-get package manager:


sudo apt-get install openjdk-8-jdk maven lintian

* lintian is needed when compiling debian package
* jdk8 is needed to compile booter and debian package

Add the JDK8 to your environment variable JAVA_HOME. Make sure to quit the terminal session if you're logging using SSH or simply open up a new terminal after making the changes.


sudo nano ~/.bashrc_profile
export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt/


Downloading and Compile libresonic Source Code

mkdir ~/libresonic
cd ~/libresonic
git clone git://github.com/Libresonic/libresonic.git
cd libresonic
git checkout develop
mvn package
mvn -P full -pl libresonic-booter -am install
mvn -P full -pl libresonic-installer-debian/ -am install
sudo dpkg -i ./libresonic-installer-debian/target/libresonic-*.deb


Modifying libresonic Service File

After installing the .deb package, open /etc/default/libresonic which is the service unit file for libresonic that is started everytime Raspberry Pi is booted. Modify the LIBRESONIC_ARGS to use the port that you want.

The following arguments will run libresonic on port 4041. Make sure to do port forwarding on your router to allow external access to your libresonic music server.

LIBRESONIC_ARGS="--max-memory=150 --port=4041 --context-path=/libresonic"

Running libresonic Service

After making the changes above, try restarting the libresonic service and make sure it is up and running correctly.

sudo systemctl restart libresonic
systemctl status libresonic 

You should see the following output if the service is up and running successfully.


libresonic.service - LSB: Libresonic daemon
   Loaded: loaded (/etc/init.d/libresonic)
   Active: active (running) since Sat 2016-10-29 19:43:07 UTC; 11h ago
  Process: 1650 ExecStop=/etc/init.d/libresonic stop (code=exited, status=0/SUCCESS)
  Process: 1664 ExecStart=/etc/init.d/libresonic start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/libresonic.service
           └─1679 java -Xmx150m -Dlibresonic.home=/var/libresonic -Dlibresonic.host=0.0.0.0 -Dlibresonic.port=40...

Oct 29 19:43:07 raspberrypi libresonic[1664]: Started Libresonic [PID 1679, /var/libresonic/libresonic_sh.log]
Oct 29 19:43:07 raspberrypi systemd[1]: Started LSB: Libresonic daemon.


There are two log files related to libresonic that you can inspect libresonic program status. You will have to switch to root superuser account to view these logs files since /var/libresonic ownership is assigned to root.

sudo su
tail -f /var/libresonic/libresonic.log
tail -f /var/libresonic/libresonic_sh.log

In my case I'm seeing a lot of Garbage Collection messages on libresonic_sh.log such as the following. Not sure whether it is important but I simply ignore them for now. You will have to wait for a couple of minutes before the libresonic

[GC (Allocation Failure)  13424K->11214K(16128K), 0.0494979 secs]
[GC (Allocation Failure)  15822K->13954K(18688K), 0.0664496 secs]
[Full GC (Allocation Failure)  13954K->11839K(18688K), 0.2304968 secs]
[GC (Allocation Failure)  20031K->16776K(28824K), 0.0817065 secs]
[GC (Allocation Failure)  24968K->21643K(29848K), 0.1128707 secs]
[Full GC (Allocation Failure)  21643K->21643K(29848K), 0.3198130 secs]
[GC (Allocation Failure)  34840K->29741K(50344K), 0.2037173 secs]
[GC (Allocation Failure)  43821K->38098K(52264K), 0.2103557 secs]
[Full GC (Allocation Failure)  38098K->23955K(52264K), 0.4711993 secs]
[GC (Allocation Failure)  40211K->33697K(58104K), 0.1532793 secs]
[GC (Allocation Failure)  49953K->37336K(58104K), 0.1197363 secs]
[GC (Allocation Failure)  53592K->39362K(58104K), 0.0555118 secs]

Wait until you see the following message on libresonic_sh.log before launching libresonic Web User Interface.


Libresonic running on: http://localhost:4041/libresonic
41571 [main] INFO org.springframework.remoting.rmi.RmiServiceExporter - Looking for RMI registry at port '9412'
41659 [main] INFO org.springframework.remoting.rmi.RmiServiceExporter - Could not detect RMI registry - creating new one
41813 [main] INFO org.springframework.remoting.rmi.RmiServiceExporter - Binding service 'LibresonicDeployerService' to RMI registry: RegistryImpl[UnicastServerRef [liveRef: [endpoint:[127.0.1.1:9412](local),objID:[0:0:0, 0]]]]

Opening libresonic Web User Interface

Now that the libresonic service is up and running, it's time to launch your web browser and navigate to http://<YOUR-RASPBERRY-PI-IP-ADDRESS>:4041/libresonic. Everything should resemble the Subsonic UI except the logo :-)



Misc.

By default, you can find the libresonic program files on /var/libresonic. Following are the directory output after libresonic is successfully running.

root@raspberrypi:/var/libresonic# ls -alh
total 56K
drwxr-x---  8 root tomcat8 4.0K Oct 30 06:58 .
drwxr-xr-x 13 root root    4.0K Oct 29 18:17 ..
drwxr-xr-x  2 root root    4.0K Oct 30 06:58 db
drwxr-xr-x  3 root root    4.0K Oct 29 19:38 jetty
drwxr-xr-x  2 root root    4.0K Oct 30 05:37 lastfmcache
-rw-r--r--  1 root root     828 Oct 30 06:59 libresonic.log
-rw-r--r--  1 root root     928 Oct 30 06:58 libresonic.properties
-rw-r--r--  1 root root     13K Oct 30 06:59 libresonic_sh.log
drwxr-xr-x  7 root root    4.0K Oct 29 19:39 lucene2
drwxr-xr-x  9 root root    4.0K Oct 30 05:37 thumbs
drwxr-xr-x  2 root root    4.0K Oct 29 19:26 transcode



References

https://github.com/Libresonic/libresonic/blob/develop/INSTALL.md

https://www.itsfullofstars.de/2016/05/