@robg I noticed your post about getting appdaemon to autostart and was wondering if you can see what is wrong this this autostart I am trying to get working.
I think the problem is lack of environment but I canโt seem to figure out what is missing. I tried writing a wrapper shell script and sourcing .bashrc and I tried adding some direct environment variable like HOME and PATH.
The logs donโt report any errors but they process just keeps trying to start every 3 seconds as configured in restart. So it looks like the bridge is dying as soon as it starts. It starts find when I start manually using pm2 from the command line.
Would love to help, but itโs little out of my league here.Once I work on my autostart hopefully it might give me some insight to your problem. Will advise.
@hongtat Not sure I like adding another control method but I decided to try. Are you using this on a raspberry pi?
I followed your steps and restart of supervisor fails
pi@flicpi3:/usr/bin$ sudo systemctl restart supervisor.service
Job for supervisor.service failed. See โsystemctl status supervisor.serviceโ and โjournalctl -xnโ for details.
pi@flicpi3:/usr/bin$ systemctl status supervisor.service
รข supervisor.service - LSB: Start/stop supervisor
Loaded: loaded (/etc/init.d/supervisor)
Active: failed (Result: exit-code) since Sun 2017-02-26 02:18:55 HST; 15s ago
Process: 16743 ExecStop=/etc/init.d/supervisor stop (code=exited, status=0/SUCCESS)
Process: 16749 ExecStart=/etc/init.d/supervisor start (code=exited, status=2)
Basically itโs failing the same as my attempt to get the smartthings bridge started with the standard systemctl config. If I take the smartthings config file out of conf.d then supervisor starts fine.
Question did you install supervisor as root? I did not sure if you did.
If you didnโt do you know how to uninstall and re-install as whichever user you installed as?
If you did install as root then I think supervisor doesnโt solve my initial issue.
After reboot it threw an error that helped me find a mistake in my config file. I somehow missed the header line [program:smartthings-mqtt-bridge]. Adding that is works.
I also changed your config a bit to let the bridge run as pi user instead of root. Seems safer that way.
I just tried this today and here was what I found out I could do on my Pi3
pm2 autostart systemd -u pi
In my case, somehow I had smartthings mqtt bridge installed as root so I had to start pm2 with root
sudo pm2 autostart systemd -u root
Then start the bridge:
sudo pm2 start smartthings-mqtt-bridge
Then reboot my PI and it will auto start pm2 and also the bridge.
One more thing I noticed on the first few tries, was that the default timeout = 8 seconds is too shortโฆ so it keeps failling, so I modified the โ/etc/systemd/system/pm2-root.serviceโ to change the timeout = 30.