9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] plumber: remove $plumbsrv, add optional srvname, usage check
@ 2021-09-07 17:46 qwx
  2021-09-07 22:06 ` umbraticus
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: qwx @ 2021-09-07 17:46 UTC (permalink / raw)
  To: 9front

Plumber both posts a service to /srv and sets a $plumbsrv environment
variable.  Our libplumb no longer uses $plumbsrv and nothing else
does.  It's a silly hack;  rc doesn't update /env immediately, and
scripts, which for instance set up subrios, cannot rely on it to
clean up the plumber at the end.

Instead, add the option to specify a srvname, actually check for some
common errors and print a usage string.

Thanks to Ori for input and a preliminary patch.  Thoughts?

Cheers,
qwx

diff 87a823332f9eaa4ff1e72f8524f6e59d1cc4f407 uncommitted
--- a//sys/man/4/plumber
+++ b//sys/man/4/plumber
@@ -6,6 +6,9 @@
 [
 .B -p
 .I plumbing
+] [
+.B -s
+.I srvname
 ]
 .SH DESCRIPTION
 The
@@ -31,11 +34,17 @@
 and a set of output
 .I ports
 for dispatching messages to applications.
+.PP
 The service is also published as a
 .IR srv (4)
-file, named in
-.BR $plumbsrv ,
+file,
+.IR srvname ,
 for mounting elsewhere.
+By default, its name is a dot-separated concatenation
+of the program's name and a process id.
+A different one can be specified via the
+.B -s
+option.
 .PP
 Programs use
 .B write
--- a//sys/src/cmd/plumb/fsys.c
+++ b//sys/src/cmd/plumb/fsys.c
@@ -218,9 +218,10 @@
 	clock = getclock();
 	if(cexecpipe(&mntfd, &srvfd) < 0)
 		error("can't create pipe: %r");
-	sprint(srvfile, "/srv/plumb.%s.%d", user, getpid());
-	if(putenv("plumbsrv", srvfile) < 0)
-		error("can't write $plumbsrv: %r");
+	if(srvname == nil)
+		snprint(srvfile, sizeof(srvfile), "/srv/plumb.%s.%d", user, getpid());
+	else
+		snprint(srvfile, sizeof(srvfile), "/srv/%s", srvname);
 	fd = create(srvfile, OWRITE|OCEXEC|ORCLOSE, 0600);
 	if(fd < 0)
 		error("can't create /srv file: %r");
--- a//sys/src/cmd/plumb/plumber.c
+++ b//sys/src/cmd/plumb/plumber.c
@@ -15,6 +15,7 @@
 int	printerrors=1;
 jmp_buf	parsejmp;
 char	*lasterror;
+char	*srvname;
 
 void
 makeports(Ruleset *rules[])
@@ -38,6 +39,13 @@
 }
 
 void
+usage(void)
+{
+	fprint(2, "usage: %s [-p plumbfile] [-s srvname]\n", argv0);
+	exits("usage");
+}
+
+void
 threadmain(int argc, char *argv[])
 {
 	char buf[512];
@@ -48,7 +56,13 @@
 
 	ARGBEGIN{
 	case 'p':
-		plumbfile = ARGF();
+		plumbfile = EARGF(usage());
+		break;
+	case 's':
+		srvname = EARGF(usage());
+		break;
+	default:
+		usage();
 		break;
 	}ARGEND
 
--- a//sys/src/cmd/plumb/plumber.h
+++ b//sys/src/cmd/plumb/plumber.h
@@ -92,3 +92,4 @@
 char		*lasterror;
 char		**ports;
 int		nports;
+char		*srvname;

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-07 17:46 [9front] plumber: remove $plumbsrv, add optional srvname, usage check qwx
@ 2021-09-07 22:06 ` umbraticus
  2021-09-08  8:51   ` sirjofri
  2021-09-08 14:18 ` ori
  2021-09-08 14:29 ` kvik
  2 siblings, 1 reply; 11+ messages in thread
From: umbraticus @ 2021-09-07 22:06 UTC (permalink / raw)
  To: 9front

yes, please. named srv has long been needed

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-07 22:06 ` umbraticus
@ 2021-09-08  8:51   ` sirjofri
  0 siblings, 0 replies; 11+ messages in thread
From: sirjofri @ 2021-09-08  8:51 UTC (permalink / raw)
  To: 9front

I didn't look at the patch, but yes, please do this.

In the past I sometimes had to rename the srv file...

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-07 17:46 [9front] plumber: remove $plumbsrv, add optional srvname, usage check qwx
  2021-09-07 22:06 ` umbraticus
@ 2021-09-08 14:18 ` ori
  2021-09-08 14:29 ` kvik
  2 siblings, 0 replies; 11+ messages in thread
From: ori @ 2021-09-08 14:18 UTC (permalink / raw)
  To: 9front

Quoth qwx@sciops.net:
> Plumber both posts a service to /srv and sets a $plumbsrv environment
> variable.  Our libplumb no longer uses $plumbsrv and nothing else
> does.  It's a silly hack;  rc doesn't update /env immediately, and
> scripts, which for instance set up subrios, cannot rely on it to
> clean up the plumber at the end.
> 
> Instead, add the option to specify a srvname, actually check for some
> common errors and print a usage string.
> 
> Thanks to Ori for input and a preliminary patch.  Thoughts?
> 
> Cheers,
> qwx
> 

Since this removes '$srvname': is anyone using it at the moment?


otherwise, this looks good to me.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-07 17:46 [9front] plumber: remove $plumbsrv, add optional srvname, usage check qwx
  2021-09-07 22:06 ` umbraticus
  2021-09-08 14:18 ` ori
@ 2021-09-08 14:29 ` kvik
  2021-09-08 17:35   ` qwx
  2 siblings, 1 reply; 11+ messages in thread
From: kvik @ 2021-09-08 14:29 UTC (permalink / raw)
  To: 9front

Quoth qwx@sciops.net:
> It's a silly hack;  rc doesn't update /env immediately, and
> scripts, which for instance set up subrios, cannot rely on it to
> clean up the plumber at the end.

Adding also the usual -m mount flag to plumber would perhaps solve
this problem for you more naturally.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-08 14:29 ` kvik
@ 2021-09-08 17:35   ` qwx
  2021-09-09 15:07     ` kvik
  2021-09-09 15:21     ` kvik
  0 siblings, 2 replies; 11+ messages in thread
From: qwx @ 2021-09-08 17:35 UTC (permalink / raw)
  To: 9front

> Quoth qwx@sciops.net:
> > It's a silly hack;  rc doesn't update /env immediately, and
> > scripts, which for instance set up subrios, cannot rely on it to
> > clean up the plumber at the end.
> 
> Adding also the usual -m mount flag to plumber would perhaps solve
> this problem for you more naturally.

I'm not sure I understand what you mean.  My problem is that a
service file is posted which I can't remove if I don't know its
name.  The mount point on the other hand is always /mnt/plumb.

Did I understand you correctly?

Thanks,
qwx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-08 17:35   ` qwx
@ 2021-09-09 15:07     ` kvik
  2021-09-09 15:21     ` kvik
  1 sibling, 0 replies; 11+ messages in thread
From: kvik @ 2021-09-09 15:07 UTC (permalink / raw)
  To: 9front

Quoth qwx@sciops.net:
> My problem is that a service file is posted which I can't remove
> if I don't know its name.

My point is that with the -m flag you might not need to post the
srv file to start with and the plumber process would go away
together with the namespace.

This assumes you don't need the srv file.
You might.
I usually don't.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-08 17:35   ` qwx
  2021-09-09 15:07     ` kvik
@ 2021-09-09 15:21     ` kvik
  2021-09-09 18:05       ` qwx
  1 sibling, 1 reply; 11+ messages in thread
From: kvik @ 2021-09-09 15:21 UTC (permalink / raw)
  To: 9front

> Quoth qwx@sciops.net:
The mount point on the other hand is always /mnt/plumb.

Wow, I'm drunk and dumb and stupid. Yes, of course the -m flag
alone doesn't change anything.

The option I implied is only posting the srv file when requested
whence you wouldn't need to clean it up afterwards in the usual
case.

Sorry for confusion.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-09 15:21     ` kvik
@ 2021-09-09 18:05       ` qwx
  2021-09-09 18:16         ` qwx
  2021-09-10 21:05         ` qwx
  0 siblings, 2 replies; 11+ messages in thread
From: qwx @ 2021-09-09 18:05 UTC (permalink / raw)
  To: 9front

> My point is that with the -m flag you might not need to post the
> srv file to start with and the plumber process would go away
> together with the namespace.
[...]
> The option I implied is only posting the srv file when requested
> whence you wouldn't need to clean it up afterwards in the usual
> case.

Yeah, I see what you mean.  Right now, the plumber doesn't have an
option not to post a srv file, and I'm not sure -m will work nicely
because libplumb relies on it being mounted there.

It makes sense that $plumbsrv be ejected, and I don't see anyone
or anything using it;  on the other hand, I'm not sure we can only
optionally post a service file without breaking people's setups.
I think being able to specify another name is enough.  The program
doesn't use postmountsrv(2) or other srv(2) shit, so we'd have to
add more code for an option to disable this or refactor or
something, I don't know.

I propose that we just push the patch as is unless someone sees a
better solution.

Thanks!
qwx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-09 18:05       ` qwx
@ 2021-09-09 18:16         ` qwx
  2021-09-10 21:05         ` qwx
  1 sibling, 0 replies; 11+ messages in thread
From: qwx @ 2021-09-09 18:16 UTC (permalink / raw)
  To: 9front

> Yeah, I see what you mean.  Right now, the plumber doesn't have an
> option not to post a srv file, and I'm not sure -m will work nicely
> because libplumb relies on it being mounted there.

That's bullshit, it's only the default (cf. plumb(2)).  Sorry!

qwx

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [9front] plumber: remove $plumbsrv, add optional srvname, usage check
  2021-09-09 18:05       ` qwx
  2021-09-09 18:16         ` qwx
@ 2021-09-10 21:05         ` qwx
  1 sibling, 0 replies; 11+ messages in thread
From: qwx @ 2021-09-10 21:05 UTC (permalink / raw)
  To: 9front

Pushed as is.

Thanks for the input, everyone!

qwx

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-09-10 21:21 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 17:46 [9front] plumber: remove $plumbsrv, add optional srvname, usage check qwx
2021-09-07 22:06 ` umbraticus
2021-09-08  8:51   ` sirjofri
2021-09-08 14:18 ` ori
2021-09-08 14:29 ` kvik
2021-09-08 17:35   ` qwx
2021-09-09 15:07     ` kvik
2021-09-09 15:21     ` kvik
2021-09-09 18:05       ` qwx
2021-09-09 18:16         ` qwx
2021-09-10 21:05         ` qwx

9front - general discussion about 9front

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/9front

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 9front 9front/ https://inbox.vuxu.org/9front \
		9front@9front.org
	public-inbox-index 9front

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.9front


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git