UniFi controller not starting on Linux
I have previously written on how to setup Ubiquiti UniFi controller on openSUSE (an unsupported distribution). I don't tend to leave my controller running as it's written in Java, which is a terrible resource hog. There is no need to have the controller running once the access points have been configured. Recently though I wanted to do some changes to my configuration and found that the controller would not start.
Clearing the logs in the logs directory and trying to start up the system showed that only the UniFi process was starting and the mongo database instance wasn't spawning (no corresponding log file). All that was being written to the server.log file was:
[2018-04-17 19:38:48,995] <launcher> INFO system - ====================================================================== [2018-04-17 19:38:48,996] <launcher> INFO system - UniFi 5.7.23 (build atag_5.7.23_10670 - release) is started [2018-04-17 19:38:48,996] <launcher> INFO system - ====================================================================== [2018-04-17 19:38:49,001] <launcher> INFO system - BASE dir:/usr/local/bin/unifi [2018-04-17 19:38:49,008] <launcher> INFO system - Current System IP: x.x.x.x [2018-04-17 19:38:49,009] <launcher> INFO system - Hostname: xxxxx [2018-04-17 19:38:50,365] <launcher> INFO db - waiting for db connection... [2018-04-17 19:38:50,866] <launcher> INFO db - Connecting to mongodb://127.0.0.1:27117 [2018-04-17 19:38:51,492] <db-server> ERROR system - [exec] error, rc=2 [2018-04-17 19:38:51,492] <db-server> INFO db - DbServer stopped [2018-04-17 19:38:55,516] <db-server> ERROR system - [exec] error, rc=2 [2018-04-17 19:38:55,519] <db-server> INFO db - DbServer stopped
Confirming that mongo wasn't starting up. I tried a little bit of troubleshooting by extracting the log4j properties file from the ace.jar archive and starting java with increased logging, but it didn't tell me anything more useful than: mongo isn't starting.
Fortunately I am not the only person to have encountered the issue and a post on the Ubiquiti forum highlights that the Unifi controller is incompatible with mongo 3.6 due to an incorrect argument that is trying to spawn the process. The fudge is to intercept the starting of monogo and clean the arguments.
For the generic Linux install, there is a symbolic link: bin/mongod that is called to start the mongo instance. This can be overwritten with the suggested script, changing the path for mongod as appropriate.
#!/bin/bash cleaned_args=$(echo $* | sed -e 's/--nohttpinterface//') exec /usr/sbin/mongod ${cleaned_args}
Be sure to set the script as executable with chmod +x monogd.
You should now be able to get your controller back up and running.