* [PATCH] prserv: add --status to list running servers
@ 2026-08-24 4:50 Babanpreet Singh
2026-08-30 21:55 ` Babanpreet Singh
2026-09-07 19:58 ` [bitbake-devel] " Richard Purdie
0 siblings, 2 replies; 4+ messages in thread
From: Babanpreet Singh @ 2026-08-24 4:50 UTC (permalink / raw)
To: bitbake-devel; +Cc: Michael Opdenacker, Babanpreet Singh
bitbake-prserv could start and stop a server but not say what is
running. Add --status: it reads every /tmp/PRServer_<ip>_<port>.pid,
reports each server as running (with its pid) or as a stale pidfile,
and exits 0 if at least one server is alive, 1 otherwise.
Extend the ScriptTests start/stop lifecycle with status checks in
both states.
[YOCTO #10865]
Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
---
bin/bitbake-prserv | 7 +++++++
lib/prserv/serv.py | 23 +++++++++++++++++++++++
lib/prserv/tests.py | 16 +++++++++++++++-
3 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/bin/bitbake-prserv b/bin/bitbake-prserv
index c26362b2e..8413c585f 100755
--- a/bin/bitbake-prserv
+++ b/bin/bitbake-prserv
@@ -64,6 +64,11 @@ def main():
action="store_true",
help="stop daemon",
)
+ parser.add_argument(
+ "--status",
+ action="store_true",
+ help="list PR servers running on this machine",
+ )
parser.add_argument(
"--host",
help="ip address to bind",
@@ -102,6 +107,8 @@ def main():
)
elif args.stop:
ret=prserv.serv.stop_daemon(args.host, args.port)
+ elif args.status:
+ ret=prserv.serv.status_daemon()
else:
ret=parser.print_help()
return ret
diff --git a/lib/prserv/serv.py b/lib/prserv/serv.py
index e17588630..322c22a0f 100644
--- a/lib/prserv/serv.py
+++ b/lib/prserv/serv.py
@@ -388,6 +388,29 @@ def stop_daemon(host, port):
return 0
+def status_daemon():
+ import glob
+ running = 0
+ for pidfile in sorted(glob.glob(PIDPREFIX % ("*", "*"))):
+ root, _ = os.path.splitext(os.path.basename(pidfile))
+ parts = root.split("_")
+ ip, port = "_".join(parts[1:-1]), parts[-1]
+ try:
+ with open(pidfile) as pf:
+ pid = int(pf.readline().strip())
+ except (IOError, ValueError):
+ sys.stderr.write("Ignoring unreadable pidfile %s\n" % pidfile)
+ continue
+ if is_running(pid):
+ print("PRServer running at %s:%s (pid %s)" % (ip, port, pid))
+ running += 1
+ else:
+ print("Stale pidfile %s (pid %s not running)" % (pidfile, pid))
+ if not running:
+ print("No PRServer running.")
+ return 1
+ return 0
+
def is_running(pid):
try:
os.kill(pid, 0)
diff --git a/lib/prserv/tests.py b/lib/prserv/tests.py
index df0c00300..518d5c441 100644
--- a/lib/prserv/tests.py
+++ b/lib/prserv/tests.py
@@ -381,8 +381,22 @@ class ScriptTests(unittest.TestCase):
except subprocess.CalledProcessError as e:
self.fail("Failed to start bitbake-prserv: %s" % e.returncode)
- def test_2_stop_bitbake_prserv(self):
+ def test_2_status_bitbake_prserv(self):
+ result = subprocess.run([BIN_DIR / "bitbake-prserv", "--status"],
+ capture_output=True, text=True)
+ self.assertEqual(result.returncode, 0,
+ "Expected a running PRServer: %s" % result.stdout)
+ self.assertIn(":8585 (pid ", result.stdout)
+
+ def test_3_stop_bitbake_prserv(self):
try:
subprocess.check_call([BIN_DIR / "bitbake-prserv", "--stop"])
except subprocess.CalledProcessError as e:
self.fail("Failed to stop bitbake-prserv: %s" % e.returncode)
+
+ def test_4_status_stopped_bitbake_prserv(self):
+ result = subprocess.run([BIN_DIR / "bitbake-prserv", "--status"],
+ capture_output=True, text=True)
+ self.assertEqual(result.returncode, 1,
+ "Expected no running PRServer: %s" % result.stdout)
+ self.assertNotIn(":8585 (pid ", result.stdout)
--
2.43.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] prserv: add --status to list running servers
2026-08-24 4:50 [PATCH] prserv: add --status to list running servers Babanpreet Singh
@ 2026-08-30 21:55 ` Babanpreet Singh
2026-09-07 19:58 ` [bitbake-devel] " Richard Purdie
1 sibling, 0 replies; 4+ messages in thread
From: Babanpreet Singh @ 2026-08-30 21:55 UTC (permalink / raw)
To: bitbake-devel; +Cc: Richard Purdie, Michael Opdenacker, Babanpreet Singh
Hi,
A gentle ping on this one. bitbake master has moved since the send
(now 18cca50ba); I've checked the patch still applies cleanly, so no
rebase is needed. Happy to rebase and resend if that's more convenient.
Thanks,
Baban
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [bitbake-devel] [PATCH] prserv: add --status to list running servers
2026-08-24 4:50 [PATCH] prserv: add --status to list running servers Babanpreet Singh
2026-08-30 21:55 ` Babanpreet Singh
@ 2026-09-07 19:58 ` Richard Purdie
2026-09-15 5:53 ` Babanpreet Singh
1 sibling, 1 reply; 4+ messages in thread
From: Richard Purdie @ 2026-09-07 19:58 UTC (permalink / raw)
To: bbnpreetsingh, bitbake-devel; +Cc: Michael Opdenacker
On Mon, 2026-08-24 at 04:50 +0000, Baban via lists.openembedded.org wrote:
> bitbake-prserv could start and stop a server but not say what is
> running. Add --status: it reads every /tmp/PRServer_<ip>_<port>.pid,
> reports each server as running (with its pid) or as a stale pidfile,
> and exits 0 if at least one server is alive, 1 otherwise.
>
> Extend the ScriptTests start/stop lifecycle with status checks in
> both states.
>
> [YOCTO #10865]
>
> Signed-off-by: Babanpreet Singh <bbnpreetsingh@gmail.com>
> ---
> bin/bitbake-prserv | 7 +++++++
> lib/prserv/serv.py | 23 +++++++++++++++++++++++
> lib/prserv/tests.py | 16 +++++++++++++++-
> 3 files changed, 45 insertions(+), 1 deletion(-)
Thanks for this, I've been meaning to do this for a long time!
Unfortunately this patch does seem to be causing failures in our
automated testing:
https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4607
I did wonder if the code needs to cope with the port already being in
use too?
Cheers,
Richard
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [bitbake-devel] [PATCH] prserv: add --status to list running servers
2026-09-07 19:58 ` [bitbake-devel] " Richard Purdie
@ 2026-09-15 5:53 ` Babanpreet Singh
0 siblings, 0 replies; 4+ messages in thread
From: Babanpreet Singh @ 2026-09-15 5:53 UTC (permalink / raw)
To: bitbake-devel; +Cc: Richard Purdie, Michael Opdenacker, Babanpreet Singh
On Mon, 2026-09-07 at 20:58 +0100, Richard Purdie wrote:
> Unfortunately this patch does seem to be causing failures in our
> automated testing:
>
> https://autobuilder.yoctoproject.org/valkyrie/#/builders/48/builds/4607
>
> I did wonder if the code needs to cope with the port already being in
> use too?
Thanks, and sorry for the noise. The server dies right after writing
its pidfile there. The old stop test didn't catch that either, since
--stop is happy with a stale pidfile. I can't tell from the logs what
kills it on the workers, but a busy port gives me the same failure
locally. I'll send a v2 that makes --start wait for the server and
fail with its error and puts --status on top of that.
Thanks,
Baban
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-15 5:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-24 4:50 [PATCH] prserv: add --status to list running servers Babanpreet Singh
2026-08-30 21:55 ` Babanpreet Singh
2026-09-07 19:58 ` [bitbake-devel] " Richard Purdie
2026-09-15 5:53 ` Babanpreet Singh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.