Enhancement Request - Set Process Title

40 views
Skip to first unread message

radio...@gmail.com

unread,
Jan 1, 2025, 2:34:07 PMJan 1
to weewx-de...@googlegroups.com

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) 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

 

cl...@n7qnm.net

unread,
Jan 1, 2025, 2:39:39 PMJan 1
to weewx-de...@googlegroups.com

Oops!

 

The call should be

setproctitle.setproctitle(“weewx”)

Tom Keffer

unread,
Jan 1, 2025, 5:12:57 PMJan 1
to cl...@n7qnm.net, weewx-de...@googlegroups.com
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

--
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 weewx-developm...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/weewx-development/113601db5c84%24e34b4140%24a9e1c3c0%24%40n7qnm.net.

Steven Sheeley

unread,
Jan 1, 2025, 6:16:19 PMJan 1
to weewx-development
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.
Reply all
Reply to author
Forward
0 new messages