diff --git a/source/_docs/autostart/systemd.markdown b/source/_docs/autostart/systemd.markdown index 0b15799e1ee..9dbcdae75e5 100644 --- a/source/_docs/autostart/systemd.markdown +++ b/source/_docs/autostart/systemd.markdown @@ -18,10 +18,14 @@ $ ps -p 1 -o comm= If the preceding command returns the string `systemd`, you are likely using `systemd`. -If you want Home Assistant to be launched automatically, an extra step is needed to setup `systemd`. You need a service file to control Home Assistant with `systemd`. If you are using a Raspberry Pi with Raspbian then replace the `[your user]` with `pi` otherwise use your user you want to run Home Assistant. `ExecStart` contains the path to `hass` and this may vary. Check with `whereis hass` for the location. +If you want Home Assistant to be launched automatically, an extra step is needed to setup `systemd`. A service file is needed to control Home Assistant with `systemd`. The template below should be created using a text editor. Note, root permissions via 'sudo' will likely be needed. The following should be noted to modify the template: -```bash -$ su -c 'cat <> /etc/systemd/system/home-assistant@.service ++ `ExecStart` contains the path to `hass` and this may vary. Check with `whereis hass` for the location. ++ If running Home Assistant in a python virtual environment or a docker, please skip to section below. ++ For most systems, the file is `/etc/systemd/system/home-assistant@[your user].service` with [your user] replaced by the user account that Home Assistant will run as - normally `homeassistant`. For Ubuntu 16.04, the file is `/lib/systemd/system/home-assistant.service` and requires running this command `sudo ln -s /lib/systemd/system/home-assistant.service /etc/systemd/system/home-assistant.service` after file is created. ++ If unfamiliar with command line text editors, `sudo nano -w [filename]` can be used with `[filename]` replaced with the full path to the file. Ex. `sudo nano -w /etc/systemd/system/home-assistant@homeassistant.service`. After text entered, press CTRL-X then press Y to save and exit. + +``` [Unit] Description=Home Assistant After=network.target @@ -33,30 +37,9 @@ ExecStart=/usr/bin/hass [Install] WantedBy=multi-user.target -EOF' ``` -For Ubunt 16.04 use this commands. Notice that files are saved in a slightly diffrent path - -```bash -$ su -c 'cat <> /lib/systemd/system/home-assistant.service -[Unit] -Description=Home Assistant -After=network.target - -[Service] -Type=simple -User=%i -ExecStart=/usr/local/bin/hass - -[Install] -WantedBy=multi-user.target -EOF' -``` - -``` sudo ln -s /lib/systemd/system/home-assistant.service /etc/systemd/system/home-assistant.service``` - -If you've setup Home Assistant in `virtualenv` following our [python installation guide](https://home-assistant.io/getting-started/installation-virtualenv/) or [manual installation guide for raspberry pi](https://home-assistant.io/getting-started/installation-raspberry-pi/), the following template should work for you. +If you've setup Home Assistant in `virtualenv` following our [python installation guide](https://home-assistant.io/getting-started/installation-virtualenv/) or [manual installation guide for raspberry pi](https://home-assistant.io/getting-started/installation-raspberry-pi/), the following template should work for you. If Home Assistant install is not located at `/srv/homeassistant`, please modify the `Enviroment=` and `ExecStart=` lines appropriately. ``` [Unit] @@ -94,18 +77,33 @@ ExecStopPost=/usr/bin/docker rm -f home-assistant-%i WantedBy=multi-user.target ``` -You need to reload `systemd` to make the daemon aware of the new configuration. Enable and launch Home Assistant after that. +You need to reload `systemd` to make the daemon aware of the new configuration. ```bash $ sudo systemctl --system daemon-reload +``` + +To have Home Assistant start automatically at boot, enable the service. + +```bash $ sudo systemctl enable home-assistant@[your user] +``` + +To disable the automatic start, use this command. + +```bash +$ sudo systemctl disable home-assistant@[your user] +``` + +To start Home Assistant now, use this command. +```bash $ sudo systemctl start home-assistant@[your user] ``` -If everything went well, `sudo systemctl start home-assistant@[your user]` should give you a positive feedback. +You can also substitute the `start` above with `stop` to stop Home Assistant, `restart` to restart Home Assistant, and 'status' to see a brief status report as seen below. ```bash -$ sudo systemctl status home-assistant@[your user] -l +$ sudo systemctl status home-assistant@[your user] ● home-assistant@fab.service - Home Assistant for [your user] Loaded: loaded (/etc/systemd/system/home-assistant@[your user].service; enabled; vendor preset: disabled) Active: active (running) since Sat 2016-03-26 12:26:06 CET; 13min ago @@ -119,10 +117,10 @@ $ sudo systemctl status home-assistant@[your user] -l To get Home Assistant's logging output, simple use `journalctl`. ```bash -$ journalctl -f -u home-assistant@[your user] +$ sudo journalctl -f -u home-assistant@[your user] ``` -Because the log can scroll quite quickly, you might want to open a second terminal to view only the errors: +Because the log can scroll quite quickly, you can select to view only the error lines: ```bash -$ journalctl -f -u home-assistant@[your user] | grep -i 'error' +$ sudo journalctl -f -u home-assistant@[your user] | grep -i 'error' ```