4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Raspberry Pi (Pi3 Raspbian 7.0 Jesssie) でHomebridgeをdaemon化するために、systemdに登録する

Last updated at Posted at 2017-08-06

前提

1 homebridgeのpathが/usr/local/bin/homebridgeである

which homebridge

2 homebridgeのconfig fileを一旦、~/.homebridge/config.jsonに作成した

Homebridge daemon用のアカウントと設定ファイル用のdirを作成

# Add a new user for homebridge process
sudo useradd --system homebridge
# Add a new dir fot homebridge process to refer
sudo mkdir /var/homebridge
sudo chown homebridge:homebridge /var/homebridge/

systemd用の設定ファイルを作成する

下記の内容で、/etc/default/homebridgeを作成する

# Defaults / Configuration options for homebridge
# The following settings tells homebridge where to find the config.json file and where to persist the data (i.e. pairing and others)
HOMEBRIDGE_OPTS=-U /var/homebridge

# If you uncomment the following line, homebridge will log more 
# You can display this via systemd's journalctl: journalctl -f -u homebridge
# DEBUG=*

下記の内容で、/etc/systemd/system/homebridge.serviceを作成する

[Unit]
Description=Node.js HomeKit Server 
After=syslog.target network-online.target

[Service]
Type=simple
User=homebridge
EnvironmentFile=/etc/default/homebridge
# Adapt this to your specific setup (could be /usr/bin/homebridge)
# See comments below for more information
ExecStart=/usr/local/bin/homebridge $HOMEBRIDGE_OPTS
Restart=on-failure
RestartSec=10
KillMode=process

[Install]
WantedBy=multi-user.target

Homebridge daemon用の設定ファイルを作成する

# Cope existing config file and accesory info files for homebridge
sudo cp ~/.homebridge/config.json /var/homebridge/
sudo cp -r ~/.homebridge/persist /var/homebridge
sudo chmod -R 0777 /var/homebridge

Daemon起動

sudo systemctl daemon-reload
sudo systemctl enable homebridge
sudo systemctl start homebridge

参考

EOF

4
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?