Running cherrymusic as a service in Ubuntu 14.04 with Supervisord

In the previous blog post, I showed you how to run a music streaming service on your computer:

Today, I will guide you how to setup cherrymusic as a service using Supervisord. I love Supervisord!

I got some trouble getting cherrymusic to work with Supervisord:

* I first tried running cherrymusic with Python2: when clicking to the "browse files" link, it said that cannot browse files and throw this error in the backend:

UnicodeDecodeError: 'ascii' codec can't decode byte 0xec in position 1: ordinal not in range(128)

* Then, I switched to Python3 and also got errors, but this time, it is a fixable issue: cherrymusic can list my albums but when I clicked to one of the album, it through this error:
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 7: surrogates not allowed

this is a Python3's bug:
A workaround is to run the cherrymusic instance with LC_CTYPE="en_US.UTF-8" environment.

Here is a working Supervisord configuration for cherrymusic, /etc/supervisor/conf.d/trmusic.conf:

command=python3 cherrymusic                                                                                                           user=myusername
environment = LC_CTYPE="en_US.UTF-8"


* you need to install cherrypy module in python3 for cherrymusic to work:

$ sudo apt-get install python3-pip
$ sudo pip3 install cherrypy

* Make sure the myusername has the proper permission on cherrymusic source folder and music folder.

* Check the configuration of cherrymusic before starting it:

$ nano ~/.config/cherrymusic/cherrymusic.conf

Finally, reload Supervisord configuration to start cherrymusic:

$ sudo supervisorctl reload