<div dir="auto">FWIW, this and other recent discussions led to a few PRs and investigative issues about paths and PIDs and signals - so here's some reading for your enjoyment:<div dir="auto">* <a href="https://github.com/networkupstools/nut/pull/1724">https://github.com/networkupstools/nut/pull/1724</a></div><div dir="auto">* <a href="https://github.com/networkupstools/nut/issues/1721">https://github.com/networkupstools/nut/issues/1721</a></div><div dir="auto">* <a href="https://github.com/networkupstools/nut/issues/1728">https://github.com/networkupstools/nut/issues/1728</a></div><div dir="auto">* <a href="https://github.com/networkupstools/nut/issues/1727">https://github.com/networkupstools/nut/issues/1727</a></div><div dir="auto">* <a href="https://github.com/networkupstools/nut/pull/1719">https://github.com/networkupstools/nut/pull/1719</a></div><div dir="auto">* <a href="https://github.com/networkupstools/nut/issues/1712">https://github.com/networkupstools/nut/issues/1712</a></div><div dir="auto">* <a href="https://github.com/networkupstools/nut/issues/1714">https://github.com/networkupstools/nut/issues/1714</a></div><div dir="auto"><br></div><div dir="auto">Jim</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Dec 2, 2022, 17:19 Bill Gee <<a href="mailto:bgee@campercaver.net">bgee@campercaver.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Oops, sorry about missing your test two.  I did not read it all the way <br>
through.<br>
<br>
That test is done, and nut-server starts successfully.  Upsc will give <br>
back information about the device.  I did have to run a daemon-reload. <br>
It does complain about not finding the PID file.<br>
<br>
=================================<br>
[root@mythtv ups]# cat <br>
/etc/systemd/system/nut-server.service.d/environ.conf<br>
[Service]<br>
Environment=NUT_STATEPATH=/run/nut<br>
[root@mythtv ups]# cat <br>
/etc/systemd/system/nut-driver@.service.d/environ.conf<br>
[Service]<br>
Environment=NUT_STATEPATH=/run/nut<br>
<br>
[root@mythtv ups]# systemctl --full --no-pager status nut-server<br>
● nut-server.service - Network UPS Tools - power devices information server<br>
      Loaded: loaded (/usr/lib/systemd/system/nut-server.service; <br>
enabled; preset: disabled)<br>
     Drop-In: /etc/systemd/system/nut-server.service.d<br>
              └─environ.conf<br>
      Active: active (running) since Fri 2022-12-02 10:11:18 CST; 9s ago<br>
    Main PID: 12675 (upsd)<br>
       Tasks: 1 (limit: 9482)<br>
      Memory: 732.0K<br>
         CPU: 5ms<br>
      CGroup: /system.slice/nut-server.service<br>
              └─12675 /usr/sbin/upsd -F<br>
<br>
Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: fopen <br>
/run/nut/upsd.pid: No such file or directory<br>
Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: Could not find <br>
PID file '/run/nut/upsd.pid' to see if previous upsd instance is already <br>
running!<br>
Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: listening on ::1 <br>
port 3493<br>
Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: listening on <br>
127.0.0.1 port 3493<br>
Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: listening on ::1 port 3493<br>
Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: listening on 127.0.0.1 <br>
port 3493<br>
Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: Connected to UPS <br>
[cyberpower]: usbhid-ups-cyberpower<br>
Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: Connected to UPS <br>
[cyberpower]: usbhid-ups-cyberpower<br>
Dec 02 10:11:18 mythtv.billgee.local upsd[12675]: Running as foreground <br>
process, not saving a PID file<br>
Dec 02 10:11:18 mythtv.billgee.local nut-server[12675]: Running as <br>
foreground process, not saving a PID file<br>
=============================<br>
<br>
===============<br>
Bill Gee<br>
<br>
On 12/2/22 06:24, Simon Wilson via Nut-upsuser wrote:<br>
> Hi Bill,<br>
> <br>
> OK your test 1 and 2 line up with my ask for test 1 :)<br>
> <br>
> Have another read of the Test 2 ask please if you can:<br>
> <br>
>>> 2. Second test:- copy the edited <br>
>>> /etc/systemd/system/nut-driver@.service.d/environ.conf to <br>
>>> /etc/systemd/system/nut-server.service.d/environ.conf. So you should <br>
>>> at that point have both locations with a file saying<br>
>>>   [Service]<br>
>>>   Environment=NUT_STATEPATH=/run/nut<br>
>>> Then comment out STATEPATH line (back to default) in upsd.conf and <br>
>>> restart nut-server - does it still start, and does it still pop a <br>
>>> "Could not find PID file '/var/run/upsd.pid'" message? That tests <br>
>>> whether the drop-in file is a better, more consistent fix for now <br>
>>> (until the packages are resolved). Calling the nut-server process <br>
>>> with that variable set for upsd *even before it reads upsd.conf* may <br>
>>> remove the first error 'Could not find PID file '/var/run/upsd.pid''<br>
> <br>
> Your test 3 and 4 are not quite what is needed, unless you did copy the <br>
> environ.conf file into /etc/systemd/system/nut-server.service.d/ but <br>
> didn't say so?<br>
> <br>
> Could you please copy your nut-driver's environ.conf file to <br>
> /etc/systemd/system/nut-server.service.d/ THEN comment out the STATEPATH <br>
> line and see if nut-server starts.<br>
> <br>
> Why am I asking this><br>
> At the moment you are using one fix to resolve the driver (an <br>
> environ.conf file) and a different fix to get nut-server going <br>
> (STATEPATH). Trying to see if one fix (the environ.conf file fix) will <br>
> resolve both driver and server, and in doing so also get rid of the <br>
> error message 'Could not find PID file '/var/run/upsd.pid''.<br>
> <br>
> Simon<br>
> <br>
> ----- Message from Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank" rel="noreferrer">bgee@campercaver.net</a>> ---------<br>
>     Date: Fri, 2 Dec 2022 06:07:20 -0600<br>
>     From: Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank" rel="noreferrer">bgee@campercaver.net</a>><br>
> Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade<br>
>       To: <a href="mailto:nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">nut-upsuser@alioth-lists.debian.net</a><br>
> <br>
> <br>
>> Test 1 - I moved the environ.conf file to /tmp.  I ran systemctl <br>
>> daemon-reload, then restarted nut-driver@cyberpower.service.  Results:<br>
>><br>
>> =====================================<br>
>> [root@mythtv nut-driver@.service.d]# systemctl restart <br>
>> nut-driver@cyberpower.service<br>
>> Job for nut-driver@cyberpower.service failed because the control <br>
>> process exited with error code.<br>
>> See "systemctl status nut-driver@cyberpower.service" and "journalctl <br>
>> -xeu nut-driver@cyberpower.service" for details.<br>
>> [root@mythtv nut-driver@.service.d]# systemctl --full --no-pager <br>
>> status nut-driver@cyberpower.service<br>
>> ● nut-driver@cyberpower.service - Network UPS Tools - device driver <br>
>> for NUT device 'cyberpower'<br>
>>      Loaded: loaded (/usr/lib/systemd/system/nut-driver@.service; <br>
>> enabled; preset: disabled)<br>
>>     Drop-In: /etc/systemd/system/nut-driver@cyberpower.service.d<br>
>>              └─nut-driver-enumerator-generated-checksum.conf, <br>
>> nut-driver-enumerator-generated.conf<br>
>>      Active: activating (auto-restart) (Result: exit-code) since Fri <br>
>> 2022-12-02 05:54:03 CST; 2s ago<br>
>>     Process: 10732 ExecStartPre=/usr/bin/systemd-tmpfiles --create <br>
>> /usr/lib/tmpfiles.d/nut-client.conf (code=exited, status=0/SUCCESS)<br>
>>     Process: 10733 ExecStart=/bin/sh -c <br>
>> NUTDEV="`/usr/libexec/nut-driver-enumerator.sh <br>
>> --get-device-for-service cyberpower`" && [ -n "$NUTDEV" ] || { echo <br>
>> "FATAL: Could not find a NUT device section for service unit <br>
>> cyberpower" >&2 ; exit 1 ; } ; /usr/sbin/upsdrvctl start "$NUTDEV" <br>
>> (code=exited, status=1/FAILURE)<br>
>>         CPU: 80ms<br>
>> =========================================<br>
>><br>
>> It seems that the nut device driver requires environ.conf to be present.<br>
>><br>
>> Test 2 - I moved environ.conf back to the correct place.  I edited the <br>
>> file to use "Environment=NUT_STATEPATH=/run/nut".  I did a <br>
>> daemon-reload then started the nut-driver.  It worked - no errors.<br>
>><br>
>> Test 3 - I modified /etc/ups/upsd.conf to comment out the STATEPATH <br>
>> line.  I restarted nut-server.service.  It failed.<br>
>><br>
>> ================================<br>
>> [root@mythtv ups]# systemctl --full --no-pager status nut-server<br>
>> ● nut-server.service - Network UPS Tools - power devices information <br>
>> server<br>
>>      Loaded: loaded (/usr/lib/systemd/system/nut-server.service; <br>
>> enabled; preset: disabled)<br>
>>      Active: active (running) since Fri 2022-12-02 06:00:54 CST; 13s ago<br>
>>    Main PID: 11452 (upsd)<br>
>>       Tasks: 1 (limit: 9482)<br>
>>      Memory: 728.0K<br>
>>         CPU: 5ms<br>
>>      CGroup: /system.slice/nut-server.service<br>
>>              └─11452 /usr/sbin/upsd -F<br>
>><br>
>> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: listening on <br>
>> ::1 port 3493<br>
>> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: listening on <br>
>> 127.0.0.1 port 3493<br>
>> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: listening on ::1 <br>
>> port 3493<br>
>> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: listening on <br>
>> 127.0.0.1 port 3493<br>
>> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: /var/run is <br>
>> world readable<br>
>> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: /var/run is world <br>
>> readable<br>
>> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: Can't connect to UPS <br>
>> [cyberpower] (usbhid-ups-cyberpower): No such file or directory<br>
>> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: Can't connect <br>
>> to UPS [cyberpower] (usbhid-ups-cyberpower): No such file or directory<br>
>> Dec 02 06:00:54 mythtv.billgee.local nut-server[11452]: Running as <br>
>> foreground process, not saving a PID file<br>
>> Dec 02 06:00:54 mythtv.billgee.local upsd[11452]: Running as <br>
>> foreground process, not saving a PID file<br>
>> ===================================<br>
>><br>
>> Test 4 - I uncommented the STATEPATH line in upsd.conf.  It points to <br>
>> /run/nut.  I restarted nut-server.  Success.<br>
>><br>
>><br>
>> ===============<br>
>> Bill Gee<br>
>><br>
>> On 12/1/22 18:35, Simon Wilson via Nut-upsuser wrote:<br>
>>> Resending as original was too big for list acceptance.<br>
>>><br>
>>> Hi Bill,<br>
>>><br>
>>> /etc/systemd/system/nut-driver@.service.d/environ.conf sets the <br>
>>> nut-driver service's environment variable, such that it sees a <br>
>>> workable NUT_STATEPATH of /var/run/nut when upsdrvctl is run by the <br>
>>> service, regardless of what is set in upsd.conf, and explains why the <br>
>>> driver worked yesterday but upsd didn't.<br>
>>><br>
>>> Tests which may be interesting:<br>
>>><br>
>>> 1. First test:- move nut-driver's environ.conf file to somewhere else <br>
>>> temporarily; leave upsd.conf STATEPATH uncommented saying /run/nut; <br>
>>> restart nut-driver@cyberpower.service; and see if it runs. This tests <br>
>>> to see if it *needs* the drop-in service file *or* will work with <br>
>>> only STATEPATH explicitly set in upsd.conf to /run/nut.  If this <br>
>>> prevents the driver from working, put the environ.conf file back (but <br>
>>> edit it, it should say /run/nut, not /var/run/nut)<br>
>>><br>
>>> 2. Second test:- copy the edited <br>
>>> /etc/systemd/system/nut-driver@.service.d/environ.conf to <br>
>>> /etc/systemd/system/nut-server.service.d/environ.conf. So you should <br>
>>> at that point have both locations with a file saying<br>
>>>   [Service]<br>
>>>   Environment=NUT_STATEPATH=/run/nut<br>
>>> Then comment out STATEPATH line (back to default) in upsd.conf and <br>
>>> restart nut-server - does it still start, and does it still pop a <br>
>>> "Could not find PID file '/var/run/upsd.pid'" message? That tests <br>
>>> whether the drop-in file is a better, more consistent fix for now <br>
>>> (until the packages are resolved). Calling the nut-server process <br>
>>> with that variable set for upsd *even before it reads upsd.conf* may <br>
>>> remove the first error 'Could not find PID file '/var/run/upsd.pid''<br>
>>><br>
>>> And definitely document any changes you make to your setup as <br>
>>> subsequent package releases will likely change all of this :)<br>
>>><br>
>>> Couple more comments inline below.<br>
>>><br>
>>> Simon<br>
>>><br>
>>><br>
>>> ----- Message from Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank" rel="noreferrer">bgee@campercaver.net</a>> ---------<br>
>>>    Date: Thu, 1 Dec 2022 16:49:14 -0600<br>
>>>    From: Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank" rel="noreferrer">bgee@campercaver.net</a>><br>
>>> Subject: Re: [Nut-upsuser] NUT no longer works after 2.7 -> 2.8 upgrade<br>
>>>      To: <a href="mailto:nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">nut-upsuser@alioth-lists.debian.net</a><br>
>>><br>
>>>> Checking now - There is a file called <br>
>>>> /etc/systemd/system/nut-driver@.service.d/environ.conf.  Its <br>
>>>> contents are<br>
>>>><br>
>>>> ==========================<br>
>>>> [root@mythtv nut-driver@.service.d]# ll<br>
>>>> total 8<br>
>>>> -rw-r--r-- 1 root root 49 Nov 29 18:14 environ.conf<br>
>>>> -rw-r--r-- 1 root root 81 Nov 30 18:58 <br>
>>>> nut-driver-enumerator-generated-checksum.conf<br>
>>>><br>
>>>> [root@mythtv nut-driver@.service.d]# cat environ.conf<br>
>>>> [Service]<br>
>><br>
>> [snip]<br>
>><br>
>> _______________________________________________<br>
>> Nut-upsuser mailing list<br>
>> <a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsuser@alioth-lists.debian.net</a><br>
>> <a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
> <br>
> <br>
> ----- End message from Bill Gee <<a href="mailto:bgee@campercaver.net" target="_blank" rel="noreferrer">bgee@campercaver.net</a>> -----<br>
> <br>
> <br>
> <br>
<br>
_______________________________________________<br>
Nut-upsuser mailing list<br>
<a href="mailto:Nut-upsuser@alioth-lists.debian.net" target="_blank" rel="noreferrer">Nut-upsuser@alioth-lists.debian.net</a><br>
<a href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser" rel="noreferrer noreferrer" target="_blank">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a><br>
</blockquote></div>