home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.9k stars 30.97k forks source link

HA does not work well with PM2 #2020

Closed ttrushin closed 8 years ago

ttrushin commented 8 years ago

Make sure you run the latest version before reporting an issue. Feature requests should go in the forum: https://community.home-assistant.io/c/feature-requests

Home Assistant release (hass --version): 0.19.2

Python release (python3 --version): 3.5.1

Component/platform: Recorder(?)/Database(?)

Description of problem: I use PM2 to run a bunch of different things, including HA. Whenever I need to restart HA (always using PM2), it no longer has any 'write' access at all to the HA database. I can "fix" the issue by deleting the database manually and letting a new one be created, but this is obviously removes all of my history and states. When I start HA manually (not through PM2), it can read and write from/to the database without any problems.

Is HA creating a database with specific permissions that don't "carry over" with each restart? Am I doing something wrong here?

ttrushin commented 8 years ago

For now I seem to have resolved the issue by manually changing the permissions of the HA log and database files to "-rw-rw-rw-". Still, I'm sure I can't be the only person with this issue.

fabaff commented 8 years ago

Sorry, I don't know PM2 but I have seen similar issues while creating the systemd service unit. The problem was that HA was launched with a different user while running with --config %h/.homeassistant/ (%h pointed to the other user's directory).

Landrash commented 8 years ago

Just quickly checking the documentation.

As indicated by @fabaff. See to that the HA instance is run with the proper usage. Example: pm2 startup hass -u homeassistant2

robbiet480 commented 8 years ago

@tySwift93 Closing this. Reopen it if the suggestion @Landrash made doesn't work.