See 
if https://github.com/vinceskahan/raspi-odds-and-ends/blob/master/netmon.sh 
helps you any for trying to self-heal your wifi.  I haven't run it in years 
since I fixed my home wifi setup by switching to Ubiquiti gear and 
essentially out-radiating the badly configured neighbors, but it used to 
work for me.   Probably needs a little tweaking for modern Raspbian but it 
should be self-evident.

I wouldn't run pm2 for what you're trying to do.  Maybe supervisord but 
even that is way overkill.   Personally I'd do it in bash called 
periodically from crontab if you can figure out a way to tell when (if) you 
need to touch weewx at all.

On Sunday, March 28, 2021 at 11:30:29 AM UTC-7 [email protected] wrote:

> Totally agree with your comments.
>
> I’m trying to handle network and remote server issues for a station I 
> don’t have remote access to, and sometimes (depending on time of year) have 
> to wait a few days before I can go onsite.  So I am trying to handle 
> conditions external to WeeWX.
>
> One issue is Raspberry Pi OS “wlan0 carrier lost problem” (see 
> https://www.raspberrypi.org/forums/viewtopic.php?t=233847 for a 
> conversation).
>
> Even if I fix each problem as they arise, I’d like to have a “belts & 
> suspenders” backup solution.
>
> Regards,
>
> Garry Lockyer
> C: +1.250.689.0686 <(250)%20689-0686>
> E: [email protected]
>
>
> On Mar 28, 2021, at 11:18, Tom Keffer <[email protected]> wrote:
>
> 
>
> I don't know anything about PM2, but it would be useful to know where 
> you're trying to get. Weewx is extremely stable and can literally run for 
> years without rebooting. If it is crashing, it would be better to fix that 
> problem, rather than use a process manager.
>
> On Sun, Mar 28, 2021 at 11:11 AM [email protected] <[email protected]> 
> wrote:
>
>> PM2 (https://pm2.keymetrics.io/) is a process manager often associated 
>> with node.js apps written in Java Script. It can also manage processes 
>> written in Python (see: 
>> https://pm2.io/blog/2018/09/19/Manage-Python-Processes).
>>
>> I was not able to get PM2 working with WeeWX - has anyone got it going?
>>
>> I was able to get the example 'hello.py' script working.
>>
>> When I tried 'sudo pm2 start /home/weewx/bin/weewxd' I got the following 
>> error (viewed using 'sudo pm2 logs'):
>>
>> 1|weewxd  | /home/weewx/bin/weewxd:2
>> 1|weewxd  | #
>> 1|weewxd  | ^
>> 1|weewxd  | SyntaxError: Invalid or unexpected token
>> 1|weewxd  |     at Module._compile (internal/modules/cjs/loader.js:723:23)
>> 1|weewxd  |     at Object.Module._extensions..js 
>> (internal/modules/cjs/loader.js:789:10)
>> 1|weewxd  |     at Module.load (internal/modules/cjs/loader.js:653:32)
>> 1|weewxd  |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
>> 1|weewxd  |     at Function.Module._load 
>> (internal/modules/cjs/loader.js:585:3)
>> 1|weewxd  |     at Object.<anonymous> 
>> (/usr/lib/node_modules/pm2/lib/ProcessContainerFork.js:33:23)
>> 1|weewxd  |     at Module._compile (internal/modules/cjs/loader.js:778:30)
>> 1|weewxd  |     at Object.Module._extensions..js 
>> (internal/modules/cjs/loader.js:789:10)
>> 1|weewxd  |     at Module.load (internal/modules/cjs/loader.js:653:32)
>> 1|weewxd  |     at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
>> PM2       | App [weewxd:1] exited with code [1] via signal [SIGINT]
>> PM2       | Script /home/weewx/bin/weewxd had too many unstable restarts 
>> (16). Stopped. "errored"
>>
>> I suspected that was because PM2 uses the file extension to determine the 
>> script language so I changed the name of 'weewxd' to 'weewxd.py'.  Things 
>> progressed a little further but I got:
>>
>> /root/.pm2/logs/weewxd-out.log last 15 lines:
>> /root/.pm2/logs/weewxd-error.log last 15 lines:
>> 0|weewxd   |   File "/home/weewx/bin/weewxd.py", line 20, in <module>
>> 0|weewxd   |     import configobj
>> 0|weewxd   | ImportError: No module named configobj
>> 0|weewxd   | Traceback (most recent call last):
>> 0|weewxd   |   File "/home/weewx/bin/weewxd.py", line 20, in <module>
>> 0|weewxd   |     import configobj
>> 0|weewxd   | ImportError: No module named configobj
>> 0|weewxd   | Traceback (most recent call last):
>> 0|weewxd   |   File "/home/weewx/bin/weewxd.py", line 20, in <module>
>> 0|weewxd   |     import configobj
>> 0|weewxd   | ImportError: No module named configobj
>> 0|weewxd   | Traceback (most recent call last):
>> 0|weewxd   |   File "/home/weewx/bin/weewxd.py", line 20, in <module>
>> 0|weewxd   |     import configobj
>> 0|weewxd   | ImportError: No module named configobj
>>
>> I assume that WeeWx is starting up but the Python interpreter can't find 
>> the file for the the import, so perhaps something needs to be tweaked in 
>> PATH?  I don't want to change anything in that area with advice.
>>
>> Starting/stopping WeeWX with '/etc/init.d/weewx' works perfectly.
>>
>> Regards and thanks in advance,
>>
>> Garry
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "weewx-user" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/weewx-user/830dc248-93ad-489e-b4d8-d2169332a318n%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/weewx-user/830dc248-93ad-489e-b4d8-d2169332a318n%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "weewx-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
>
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/weewx-user/CAPq0zEB_xgjs5FmmQMiUTVqCi0dpQovyQYhoL4ENguwn0zXRxA%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/weewx-user/CAPq0zEB_xgjs5FmmQMiUTVqCi0dpQovyQYhoL4ENguwn0zXRxA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/weewx-user/197c228a-6dc1-4967-a000-3ff6aa6fe54bn%40googlegroups.com.

Reply via email to