How to build HiFi Server and run as a service for Ubuntu 16.04 / AWS


#1

There is little information online concerning the linux version of the high fidelity server, and non detailing how to build on Ubuntu 16.04 and run as a service at boot time. I wanted to share my experience here.

The documentation online suggests a Digital Ocean droplet with one GB memory. However, my own tests showed that the hifi server uses around a gig of memory itself, causing the server performance to slow, especially with regard to live audio.

I tried running the server on the free aws T1.micro tier with 1 GB and experienced terrible performance.

At the time of this writing (May 2017), the m3.medium server was the best cost/performance server. The instance can be shut down when not in use to save money. If left on 24/7, the server and hosting costs will be approximately $50 a month. Furthermore, the m3 is a step up in network speed (medium use rather than light use, no additional specifics) according to amazon.

Server setup: (much of this copied from another post here)

System:

Ubuntu 16.04 64 bit OS

I used an elastic IP to lock down a fixed ip so that we can easily assign a domain name in the future.

After provisioning the server and assigning an elastic IP, open ssh port to your up to your IP in the default security group. In order to be able to remotely administer our domain, we want to access its domain settings page from a web browser. When you run the Domain Server, it serves the settings page on port 40100. Also open ports 40100-40105 to UDP and TCP.

Install the pem key provided by amazon and install/build the server:

sudo su

apt-get update

apt-get install -y build-essential mesa-common-dev libglu1-mesa-dev libasound2 libxmu-dev libxi-dev freeglut3-dev libasound2-dev libjack0 libjack-dev libxrandr-dev libudev-dev software-properties-common git libssl-dev zlib1g-dev

add-apt-repository ppa:george-edison55/cmake-3.x

apt-get update

apt-get install -y cmake

add-apt-repository ppa:beineri/opt-qt562-xenial

apt-get update

apt-get install -y qt-latest

apt install cmake


git clone -b master https://github.com/highfidelity/hifi.git

(Or you can try stable… I’ve noticed that the latest server sometimes doesn’t play nice with the latest interface)

use: git clone -b stable --single-branch https://github.com/highfidelity/hifi.git

cd hifi

mkdir build

cd build

cmake …-DQT_CMAKE_PREFIX_PATH=/opt/qt56/lib/cmake/

make domain-server assignment-client

For testing you can do the following (pay attention to the user, as domain settings are stored in the user’s home directory… :~/.local/share/High Fidelity

tmux
./domain-server/domain-server

*Now press “Ctrl-B” and then “D” to exit but leave this process running

tmux
./assignment-client/assignment-client -n 6

*Now press “Ctrl-B” and then “D” to exit but leave this process running

However once you have everything set up and running, it’s easier to set the server up as a service. Kill the server and do the following:

Ubuntu 16.04 uses systemd for startup scripts:

First create these two files as root:

/etc/systemd/system/startHIFI-domainserver.service:

[Unit]
Description=start
HIFI domain server

[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu
ExecStart=/home/ubuntu/hifi/build/domain-server/domain-server

[Install]
WantedBy=multi-user.target
……………….

/etc/systemd/system/startHIFI-assign-client.service:
[Unit]
Description=start
HIFI assignment client server
[Service]
User=ubuntu
WorkingDirectory=/home/ubuntu/hifi/build
ExecStart=/home/ubuntu/hifi/build/assignment-client/assignment-client -n 6
Restart=always

[Install]
WantedBy=multi-user.target
…………………

Now tell systemd to read your new services:

systemctl enable startHIFI-assign-client.service

systemctl enable startHIFI-domainserver.service

systemctl daemon-reload

Now manually test your scripts before rebooting:

systemctl start startHIFI-domainserver.service

systemctl start startHIFI-assign-client.service

If everything looks good, try rebooting and see if your server comes up. Please note that I forced the service to run as user ubuntu (amazon’s default user account). Running as root caused some problems for me due to the location of the server config files.


#2

It’s bad to run anything as root anyway. Best thing to do is create a new user specifically for running hifi.


#3

Getting Error

PATH=/opt/qt56/lib/cmake" does not exist.
Specify --help for usage, or press the help button on the CMake GUI.

I really wish we’d get some official linux packages soon i’ve literally been trying to build a stable server for HiFi for a month now.

Would anyone be willing to help me? Midnight sent me his CentOS script for it but i lost it and couldn’t get it to work on Ubuntu. I’m still relatively new to all this but generally i have no problems learning to do something myself i’ve tried literally every suggestion. I’m on an EC2 Ubuntu machine as well. Everything else on my server works correctly. I understand the instructions here clearly

And i agree it’s a bad idea to run this under root when you’re assigning the service to the ubuntu user anyway you could just sudo prefix the entire instruction as needed someone could really do some damage to their system if they forgot to switch back out of root after doing this.


#4

I probably don’t have the expertise to be of much help, though I may try the compile outlined by kipartful. If I get anywhere I’ll return and post here.

But I do want to put in another vote for having a linux package. My newest and most suitable machine for running High Fidelity is a System 76 linux laptop. I’ve tried it on my older Macs and in a virtual machine and neither experience was encouraging.


#5

Good luck with that. I think they decided to abandon any kind of linux support, even though it is the most used OS in the world (especially for servers).


#6

It’s for sure not the most used operating system on the desktop.


#7

Probably not desktop but it’s the most used OS in the world, and frankly if hifi is only intended to be used on desktops then what is the point of using it to make money? (if it’s not going to make anybody money then I don’t expect it to be very popular).

According to wikipedia (if you trust wikipedia) 66% of servers run Linux. This alone is enough reason to support linux.

As far as other devices (smartphones, tablets) go, 70% use Android (linux) and another 20% run macos (which is also a linux derivative). Only a pathetic 1-2% run windows.

Needless to say, FAR FAR more people are using tablets and smartphones than desktops. Sure right now it would have no hope of running on most handheld devices but it won’t be long until handheld devices are powerful enough to easily run it and then some (long before hifi is ready for release at this rate).

A tragedy if hifi isn’t going to support linux out of the box.

I’m not even going to count the other devices (for obviously not being of interest because why would you run hifi on them), such as home appliances and automobiles which almost all run on Linux and far outnumber even handheld devices. But they get honorable mention anyway.


#8

On my windows Workstation i’ve had nothing but positive experiences in HiFi, and no problems. However i don’t use Windows Server the real server world really runs on Linux, Ubuntu is the best solution for me because it’s the only Distro i have experience with enough to troubleshoot these kinds of problems.

We were lucky to have OmegaHeron running packages for HiFi for a time. HiFi has a lot of hurdles to jump over right now but there are four major ones for me right now. I cannot reliable get an instance running in Linux for a long enough period of time to get any work done, there are currently absolutely ZERO measures in place to help you at least partially protect proprietary content, and because of that there’s nothing in place for Monetizing Assets. The Fous on VR, “Desktop VR” specifically limits the user base. VR is amazing and will no doubt change the world over time, but the majority of people still do not have affordable access to it. You’re looking at bare minimum 1500USD to get into VR. The market just isn’t currently there. Maybe once the HMD’s start dropping in price and if OSVR starts to pick up, though most Consumers are probably going to opt for the plug in and play solutions like the Oculus.

My Dev Kit 2 broke awhile back and so i can’t enjoy HiFi the way i’d like and buying a new headset is out of the question right now, I’d like to at least work on a project in HiFI, Running Sandbox from my desktop is not an acceptable long term solution, nor is purchasing another VPS to run in WIndows when i already have a properly setup Ubuntu server.

HiFi is incredible technology and I have big plans for doing something in it, but I can’t even get started at the moment and that’s a shame.