logantgt / harmony-span

A Node.JS application that allows you to trigger external webhooks from your Logitech Harmony Hub and compatible remotes.
MIT License
27 stars 14 forks source link

Server restarting every 2 secs when running in PM2 #7

Closed Jelleeelco closed 3 years ago

Jelleeelco commented 3 years ago

Hi Logan,

Not sure if this is due to my system, but I observed the following. When running the harmony-span server from command line, it works perfectly. But I wanted to make it more robust (so in case my Raspberry Pi reboots it will also reboot) and installed PM2 to manage the .js application. When I go into PM2 monit, it shows that the server is restarting every two seconds. Looking at the log, it shows the following: image

Questions:

Many thanks! Jelle..

Jelleeelco commented 3 years ago

And when adding the harmony-span.js to /etc/rc.local to run during startup, it also returns the error as per above. This is reproducable by executing:

su pi -c 'node /home/pi/harmony-span/harmony-span.js < /dev/null &'

Thanks Jelle..

logantgt commented 3 years ago

Thanks again for opening this issue. Try navigating directly to the folder where you have HarmonySpan located and try running it from there - I suspect that HarmonySpan is looking for the config file in whatever directory you start it in (so if you're in /home/pi for instance and you run HarmonySpan from a different directory, HarmonySpan might be looking in /home/pi for the config file which isn't correct).

Jelleeelco commented 3 years ago

Hi Logan,

I think you're right, but I'm not sure how to fix that. I thought I did run it from the actual folder before I created the startup file in PM2. My second attempt to have it startup using /etc/rc.local, my line added to RC.local does contain the actual folder.

I know I can run it in a screen am just detach it, but I want it "idiot proof" so that when I'm not around and the pi needs to reboot, it's all still there.

Sidenote: amazing project and amazing functionality you build! Thank you so much!

Cheers Jelle..

On Wed, 8 Jul 2020, 20:14 Logan Lowe, notifications@github.com wrote:

Thanks again for opening this issue. Try navigating directly to the folder where you have HarmonySpan located and try running it from there - I suspect that HarmonySpan is looking for the config file in whatever directory you start it in (so if you're in /home/pi for instance and you run HarmonySpan from a different directory, HarmonySpan might be looking in /home/pi for the config file which isn't correct.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AShifter/harmony-span/issues/7#issuecomment-655676610, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQGOEYWU5BG4GDZ6B33HSWDR2SZPDANCNFSM4OUJU6RQ .

Jelleeelco commented 3 years ago

Hi Logan,

It worked... I deleted the startup script from PM2. Then run PM2 from within the harmony-span folder. Then recreated the startup script. After rebooting, voila, all works.

AWESOME, this one is now closed!

Jelleeelco commented 3 years ago

Closed - fixed by running PM2 from within folder where harmony-span is located and creating start-up script from there.

Also, using 'PM2 monit' one can monitor the key presses.