Starting Hass with pm2

any idea?
my user is homeassistant… but it fail to startup

What does the log file say

3|hass | /usr/local/bin/hass:3
3|hass | # -- coding: utf-8 --
3|hass | ^
3|hass |
3|hass | SyntaxError: Invalid or unexpected token
3|hass | at new Script (vm.js:74:7)
3|hass | at createScript (vm.js:246:10)
3|hass | at Object.runInThisContext (vm.js:298:10)
3|hass | at Module._compile (internal/modules/cjs/loader.js:646:28)
3|hass | at Object.Module._extensions…js (internal/modules/cjs/loader.js:689:10)
3|hass | at Module.load (internal/modules/cjs/loader.js:589:32)
3|hass | at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
3|hass | at Function.Module._load (internal/modules/cjs/loader.js:520:3)
3|hass | at Function._load (/home/pi/.nvm/versions/node/v10.0.0/lib/node_modules/pm2/node_modules/@pm2/io/build/main/src/metrics/transaction.js:110:33)
3|hass | at Object. (/home/pi/.nvm/versions/node/v10.0.0/lib/node_modules/pm2/lib/ProcessContainerFork.js:48:21)

I think what’s more important here is how you’re starting the pm2 job. Pm2 was intended for nodejs apps, so you have to make sure you’re using the correct start params.

--interpreter=python is needed.

1 Like

I ran sudo pm2 start hass -u pi --interpreter=python

other errors:

1|hass | File “/usr/local/bin/hass”, line 7, in
1|hass | from homeassistant.main import main
1|hass | ImportError: No module named homeassistant.main
1|hass | Traceback (most recent call last):
1|hass | File “/usr/local/bin/hass”, line 7, in
1|hass | from homeassistant.main import main
1|hass | ImportError: No module named homeassistant.main
1|hass | Traceback (most recent call last):
1|hass | File “/usr/local/bin/hass”, line 7, in
1|hass | from homeassistant.main import main
1|hass | ImportError: No module named homeassistant.main
1|hass | Traceback (most recent call last):
1|hass | File “/usr/local/bin/hass”, line 7, in
1|hass | from homeassistant.main import main
1|hass | ImportError: No module named homeassistant.main

This worked for me:

pm2 start hass --interpreter=python3