2015-10-27 23:51:12 -07:00

117 lines
4.9 KiB
HTML

---
layout: page
title: "Launch Home Assistant on boot"
description: "Instructions how to setup Home Assistant to launch on boot on various platforms.."
date: 2015-9-1 22:57
sidebar: false
comments: false
sharing: true
footer: true
---
<div class='advanced-installs-container'>
<input name='advanced-installs' type='radio' id='upstart-install' checked>
<input name='advanced-installs' type='radio' id='systemd-install'>
<input name='advanced-installs' type='radio' id='osx-install'>
<label class='menu-selector upstart' for='upstart-install'>Upstart Daemon</label>
<label class='menu-selector systemd' for='systemd-install'>Systemd Daemon</label>
<label class='menu-selector osx' for='osx-install'>OS X</label>
<div class='advanced-installs upstart'>
<p>Many linux distributions use the Upstart system (or similar) for managing daemons. Typically, systems based on Debian 7 or previous use Upstart. This includes Ubuntu releases before 15.04 and all current Raspian releases. If you are unsure if your system is using Upstart, you may check with the following command:</p>
<pre class='CodeRay'>$ ps -p 1 -o comm=</pre>
<p>If the preceding command returns the string <code>init</code>, you are likely using Upstart.</p>
<p>Upstart will launch init scripts that are located in the directory <code>/etc/init.d/</code>. A sample init script for systems using Upstart is <a href="https://raw.githubusercontent.com/balloob/home-assistant/dev/script/hass-daemon">maintained by this project</a>.</p>
<p>To install this script, download it, tweak it to you liking, and install it by following the directions in the header. This script will setup Home Assistant to run when the system boots. To start/stop Home Assistant manually, issue the following commands:</p>
<pre class='CodeRay'>$ sudo service hass-daemon start
$ sudo service hass-daemon stop
</pre>
<p>When running Home Assistant with this script, the configuration directory will be located at <code>/var/opt/homeassistant</code>. This directory will contain a verbose log rather than simply an error log.</p>
<p>When running daemons, it is good practice to have the daemon run under its own user name rather than the default user's name. Instructions for setting this up are outside the scope of this document.</p>
</div> <!-- UPSTART -->
<div class='advanced-installs systemd'>
<p>Newer linux distributions are trending towards using systemd for managing daemons. Typically, systems based on Fedora or Debian 8 or later use systemd. This includes Ubuntu releases including and after 15.04, CentOS, and Red Hat. If you are unsure if your system is using systemd, you may check with the following command:</p>
<pre class='CodeRay'>$ ps -p 1 -o comm=</pre>
<p>If the preceding command returns the string <code>systemd</code>, you are likely using systemd.</p>
<p>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.</p>
<pre class='CodeRay'>$ su -c 'cat &lt;&lt;EOF >> /lib/systemd/system/home-assistant.service
[Unit]
Description=Home Assistant
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/hass
# Next line is to run as a specific user
# for Raspberry Pi users, keep it at 'pi'
User=pi
[Install]
WantedBy=multi-user.target
EOF'
</pre>
<p>You need to reload systemd to make the daemon aware of the new configuration. Enable and launch Home Assistant after that.</p>
<pre class='CodeRay'>$ sudo systemctl --system daemon-reload
$ sudo systemctl enable home-assistant
$ sudo systemctl start home-assistant
</pre>
<p>If everything went well, <code>sudo systemctl start home-assistant</code> should give you a positive feedback.</p>
<pre class='CodeRay'>$ sudo systemctl status home-assistant -l
● home-assistant.service - Home Assistant
Loaded: loaded (/usr/lib/systemd/system/home-assistant.service; disabled; vendor preset: disabled)
Active: active (running) since Thu 2015-06-25 23:38:37 CEST; 3min 13s ago
Main PID: 8557 (python3.4)
CGroup: /system.slice/home-assistant.service
└─8557 /usr/bin/python3.4 -m homeassistant
[...]
</pre>
<p>To get Home Assistant's logging output, simple use <code>journalctl</code>.</p>
<pre class='CodeRay'>$ sudo journalctl -f -u home-assistant</pre>
</div> <!-- SYSTEMD -->
<div class='advanced-installs osx'>
<p>Setting up Home Assistant to run as a background service is simple. OS X will
start it on boot and make sure it's always running.</p>
<p>To get Home Assistant installed as a background service, run:</p>
<pre class='CodeRay'>$ hass --install-osx
Home Assistant has been installed. Open it here: http://localhost:8123
</pre>
<p>Home Assistant will log to <code>~/Library/Logs/homeassistant.log</code></p>
<p>To uninstall the service, run:</p>
<pre class='CodeRay'>$ hass --uninstall-osx
Home Assistant has been uninstalled.
</pre>
</div> <!-- OSX -->
<h3><a href='/getting-started/'>&laquo; Back to Getting Started</a></h3>