Newbie - Log files

SIGTerm does a graceful shutdown. I think sigkill is not handled.

That error was cleared after I stopped and started appdaemon service.

pi@rpi3-aio:~ $ sudo systemctl stop [email protected]

pi@rpi3-aio:~ $ ps aux | grep appdaemon
pi       29857  0.0  0.1   4272  1832 pts/0    S+   10:45   0:00 grep --color=auto appdaemon

pi@rpi3-aio:~ $ sudo systemctl status  [email protected] -l
● [email protected] - AppDaemon service for homeassistant
   Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
   Active: inactive (dead) since Thu 2017-10-05 10:45:51 CDT; 9s ago
  Process: 12436 ExecStart=/usr/local/bin/appdaemon -c /home/homeassistant/.homeassistant/config (code=killed, signal=TERM)
 Main PID: 12436 (code=killed, signal=TERM)

Oct 05 10:45:38 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:38.058114 ERROR bedtimelights
Oct 05 10:45:38 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:38.058409 WARNING Disconnected from Home Assistant, retrying in 5 seconds
Oct 05 10:45:43 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:43.399982 INFO Got initial state
Oct 05 10:45:43 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:43.402323 ERROR Unable to resolve dependencies due to incorrect or circular references
Oct 05 10:45:43 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:43.402737 ERROR The following modules have unresolved dependencies:
Oct 05 10:45:43 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:43.403026 ERROR bedtimelights
Oct 05 10:45:43 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:43.403309 WARNING Disconnected from Home Assistant, retrying in 5 seconds
Oct 05 10:45:48 rpi3-aio appdaemon[12436]: 2017-10-05 10:45:48.460204 WARNING Disconnected from Home Assistant, retrying in 5 seconds
Oct 05 10:45:51 rpi3-aio systemd[1]: Stopping AppDaemon service for homeassistant...
Oct 05 10:45:51 rpi3-aio systemd[1]: Stopped AppDaemon service for homeassistant.

pi@rpi3-aio:~ $ sudo systemctl start [email protected]

pi@rpi3-aio:~ $ sudo systemctl status  [email protected] -l
● [email protected] - AppDaemon service for homeassistant
   Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
   Active: active (running) since Thu 2017-10-05 10:47:01 CDT; 2s ago
 Main PID: 29960 (appdaemon)
   CGroup: /system.slice/system-appdaemon.slice/[email protected]
           └─29960 /usr/bin/python3 /usr/local/bin/appdaemon -c /home/homeassistant/.homeassistant/config

Oct 05 10:47:01 rpi3-aio systemd[1]: Started AppDaemon service for homeassistant.
pi@rpi3-aio:~ $

For example other day I was testing following snippet in one file. I saved the file and but didn’t work right away.

# test - worked
# self.call_service('tts/google_say', entity_id='media_player.living_room_home', message='Hello from AppDaemon. Test Complete')

To make this work either I run appdaemon manually or edit appdaemon.yaml (config file) and save the file to trigger (serivce runs at this time with latest code) latest changes.

Maybe there is an easy way to test code changes which I don’t know yet.

if everything is running normal you can change files and they take effect.
if not then you have to stop and start your service.

running it manually while your service is running in the background will give you very unexpected effects.

Lessons learned. :smile: Thank you for the tip.

Another question. Though I have following settings I don’t get information written to the log files.

AppDaemon:
#logfile: STDOUT
#errorfile: STDERR
logfile: /home/homeassistant/.homeassistant/config/logs/appdaemon.log
errorfile: /home/homeassistant/.homeassistant/config/logs/appdaemonerr.log
logsize: 100000
log_generations: 3
threads: 10

pi@rpi3-aio:/home/homeassistant/.homeassistant/config/logs $ ls -lt
total 20
-rw-r–r-- 1 pi pi 9805 Oct 4 22:17 appdaemon.log
-rw-r–r-- 1 pi pi 6086 Oct 3 17:50 appdaemonerr.log

I can find any errors in the code only when I query appdaemon service status.

pi@rpi3-aio:/home/homeassistant/.homeassistant/config/logs $ sudo systemctl status [email protected] -l
[email protected] - AppDaemon service for homeassistant
Loaded: loaded (/etc/systemd/system/[email protected]; enabled)
Active: active (running) since Thu 2017-10-05 12:20:41 CDT; 8h ago
Main PID: 13753 (appdaemon)
CGroup: /system.slice/system-appdaemon.slice/[email protected]
└─13753 /usr/bin/python3 /usr/local/bin/appdaemon -c /home/homeassistant/.homeassistant/config

Oct 05 20:57:30 rpi3-aio appdaemon[13753]: File “”, line 1129, in _exec
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: File “”, line 1467, in exec_module
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: File “”, line 1572, in get_code
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: File “”, line 1532, in source_to_code
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: File “”, line 321, in _call_with_frames_removed
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: File “/home/homeassistant/.homeassistant/config/apps/dark_house.py”, line 48
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: msg=“Attention: \nIt is getting a little dark inside the house. \nI will turn on some extra lights in the living room and kitchen. \n”
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: ^
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: IndentationError: unexpected indent
Oct 05 20:57:30 rpi3-aio appdaemon[13753]: 2017-10-05 20:57:30.963746 WARNING ------------------------------------------------------------
pi@rpi3-aio:/home/homeassistant/.homeassistant/config/logs $

It depends on how your service is written, but normally the appdaemon@homeassistant in the name indicates that you are running the service as the homeassistant user. If you set up the permissions of the log files for the pi user, this process will not have access to the log files.

You can check who is running by running

ps -eaf | grep appdaemon

and seeing which user is listed.

1 Like

Obviously, I screwed up when I installed appdaemon using ‘pi’ user and outside venv. I didn’t install that under ‘homeassistant’ user.

Here are the contents of service.

pi@rpi3-aio:/etc/systemd/system $ cat [email protected]
#
#Edit top suit your environment, then copy to /etc/systemd/system
#
#run "systemd enable appdaemon" to make it start at boottime
#
[Unit]
Description=AppDaemon service for %i
After=network.target mosquitto.service

[Service]
Type=simple
User=%i
#ExecStart=/srv/homeassistant/bin/appdaemon -c /home/homeassistant/.homeassistant/config
ExecStart=/usr/local/bin/appdaemon -c /home/homeassistant/.homeassistant/config
Restart=on-failure

#
#If you are not using a default path for the config file use this:
#
#ExecStart=/usr/local/bin/appdaemon -c <path to config file>
#
[Install]
WantedBy=multi-user.target

This service is run by ‘homeassistant’ user.

pi@rpi3-aio:/home/homeassistant/.homeassistant/config/logs $ ps aux | grep appdaemon
homeass+ 12664 83.0  1.6  19976 15668 ?        Rs   08:42   0:00 /usr/bin/python3 /usr/local/bnfig
pi       12666  0.0  0.2   4272  2044 pts/0    S+   08:42   0:00 grep --color=auto appdaemon

Yes, those log files have permission only for the ‘pi’ user. :weary:

pi@rpi3-aio:/home/homeassistant/.homeassistant/config/logs $ ls -lt
total 20
-rw-r--r-- 1 pi pi 9805 Oct  4 22:17 appdaemon.log
-rw-r--r-- 1 pi pi 6086 Oct  3 17:50 appdaemonerr.log

Now I understood why the information was written these files when I run appdaemon from the command line.

is that supposed to be or should it be pi?

if your service is run as pi, and your writing rights are for pi, there should be no problem.

you say service is run by homeassistant, but is it?

i see this:

pi       12666  0.0  0.2   4272  2044 pts/0    S+   08:42   0:00 grep --color=auto appdaemon