This is a function that I use to find weewx in the process list:
def chkWeewx(self, wxName='weewx'):
try:
result = subprocess.run(
["ps", "-eo", "user:20,group:20,args"],
capture_output=True,
text=True
)
if result.returncode == 0:
processes = result.stdout.splitlines()
for line in processes:
if wxName in line:
fields = line.split(None, 2)
wxOwner = fields[0]
wxGroup = fields[1]
return True, wxName, wxOwner, wxGroup
return False, wxName, None, None
else:
return False, wxName, None, None
except Exception:
return False, wxName, None, None
and I call it in this manner
weewxRunning, self.wxName, self.wxOwner, self.wxGroup = self.chkWeewx()\
It doesn't need anything extra.
On Thursday, January 2, 2025 at 9:12:57 AM UTC+11 Tom Keffer wrote:
Unfortunately, setproctitle is not part of the standard Python library, and
would have to be installed separately. Adding a dependency for so little
value is not worth it.
If you want to use it, just add it to the file user.extensions.py. That
file is loaded before anything else.
-tk
On Wed, Jan 1, 2025 at 11:39 AM <[email protected]> wrote:
Oops!
The call should be
setproctitle.setproctitle(“weewx”)
*From:* [email protected] <[email protected]>
*Sent:* Wednesday, January 1, 2025 11:34 AM
*To:* '[email protected]' <[email protected]>
*Subject:* Enhancement Request - Set Process Title
Happy New Year!
Thanks to everyone who contributes to WeeWx.
In order to effectively find the WeeWx process in a process list, I’d like
tor suggest that weewxd set the process name when it starts.
I’ve tested the “setproctitle” library (GitHub - dvarrazzo/py-setproctitle:
A Python module to customize the process title
<https://github.com/dvarrazzo/py-setproctitle>) but would not object to
some other process.
Here’s the diff for version 5.1.0
21a22
> import setproctitle
44a46
> setproctitle("weewx")
Clay Jackson
--
You received this message because you are subscribed to the Google Groups
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/weewx-development/113601db5c84%24e34b4140%24a9e1c3c0%24%40n7qnm.net
<https://groups.google.com/d/msgid/weewx-development/113601db5c84%24e34b4140%24a9e1c3c0%24%40n7qnm.net?utm_medium=email&utm_source=footer>
.
--
You received this message because you are subscribed to the Google Groups
"weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/weewx-development/e363c8f0-3820-4278-ab9c-913d55eec365n%40googlegroups.com.