Skip to content

Standalone Mode

oznu edited this page Aug 23, 2020 · 10 revisions

READ THIS FIRST

Standalone mode is no longer recommended. Setting up Homebridge and Homebridge Config UI X with hb-service has the same benefits of standalone mode but is much easier to setup and maintain.

Full step-by-step setup guides for how to setup hb-service are available here:

For information on setting up multiple instances of Homebridge on the same machine, see the Multiple Instances section of the hb-service documentation.

How To Swap From Standalone Mode to hb-service

See How To Swap From Standalone Mode to Service Mode.


Homebridge Config UI X has the ability to run in Standalone Mode. When this mode is enabled the UI will run as a separate service to Homebridge. The main advantage of this is, should Homebridge be crashing due to a bad config or some other reason, you will still be able to access the UI to view the logs or restore a config backup.

oznu/homebridge docker users: You are already running in standalone mode if you enabled the UI using the supported method.

How It Works

After installing homebridge-config-ui-x globally using npm, you can start the UI in the same way you start homebridge. You should pass the same command line parameters you are passing to homebridge to homebridge-config-ui-x:

# Example: if you start homebridge like this:
homebridge -U /var/lib/homebridge -I

# Example: then you can start homebridge-config-ui-x in standalone mode like this:
homebridge-config-ui-x -U /var/lib/homebridge -I

You also need to tell homebridge that the UI is running in standalone mode, so it does not attempt to start it as well which will cause a clashing of ports. To do this add "standalone": true to the Config UI X section of the Homebridge config.json:

"platforms": [
    {
      "platform": "config",
      "name": "Config",
      "port": 8080,
      "standalone": true,
      ... // the rest of your config
   }
]

Configure Standalone Mode With Systemd

If you haven't yet setup Homebridge or Homebridge Config UI X using systemd see the guide here. The following instructions assume you have already setup Homebridge and the UI with systemd.

Step 1: Edit config.json to enable standalone mode

Add the "standalone": true option and update the restart command in the Config UI section of the Homebridge config.json file:

"platforms": [
    {
      "platform": "config",
      "name": "Config",
      "port": 8080,
      "standalone": true,
      "restart": "sudo -n systemctl restart homebridge homebridge-config-ui-x",
      ... // the rest of your config
   }
]

Step 2: Restart Homebridge

Restart Homebridge, the UI will no longer start:

systemctl restart homebridge

Step 3: Create a new systemd service

Use the command below to create the required /etc/systemd/system/homebridge-config-ui-x.service file:

Copy and paste this entire block into the terminal as one command!
Do not use a text editor. This template includes variables that get populated by bash as the command is executed.

cat >/etc/systemd/system/homebridge-config-ui-x.service <<EOL
[Unit]
Description=Homebridge Config UI X
After=syslog.target network-online.target

[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
ExecStart=$(which homebridge-config-ui-x) \$HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=3
KillMode=process
CapabilityBoundingSet=CAP_IPC_LOCK CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_SETGID CAP_SETUID CAP_SYS_CHROOT CAP_CHOWN CAP_FOWNER CAP_DAC_OVERRIDE CAP_AUDIT_WRITE CAP_SYS_ADMIN
AmbientCapabilities=CAP_NET_RAW

[Install]
WantedBy=multi-user.target
EOL

Step 4: Reload Systemd and Start Homebridge Config UI X

This will ensure Homebridge Config UI X starts on boot:

systemctl daemon-reload
systemctl enable homebridge-config-ui-x
systemctl start homebridge-config-ui-x

Step 5: Complete

You can now use the UI as normal.

Clone this wiki locally