PID file; VCL code generation

Christoph Schug chris+varnish-misc at schug.net
Fri Oct 13 14:24:33 CEST 2006


On Fri, Oct 13, 2006, Dag-Erling Smørgrav wrote:

> Christoph Schug <chris+varnish-misc at schug.net> writes:
> > o PID file
[...]
> 
> Yes, that would be a good idea.

In the meantime I packaged Varnish as OpenPKG package using this patch
against 1.0.1 by setting -DOPKG_PIDFILE=/foo/bar/varnishd.pid in
CPPFLAGS. Not elegant, but works for me :)

Index: bin/varnishd/mgt_child.c
--- bin/varnishd/mgt_child.c.orig	2006-09-20 19:18:51 +0200
+++ bin/varnishd/mgt_child.c	2006-10-11 22:42:04 +0200
@@ -172,6 +172,21 @@
 
 	fprintf(stderr, "start child pid %d\n", i);
 
+#ifdef OPKG_PIDFILE
+	{
+		pid_t pid;
+		FILE *fp;
+
+		pid = getpid();
+		if ((fp = fopen(OPKG_PIDFILE, "w")) == NULL) {
+			fprintf(stderr, "varnishd:ERROR: cannot write PID file '%s'\n", OPKG_PIDFILE);
+			exit(1);
+		}
+		fprintf(fp, "%ld\n", (long)pid);
+		fclose(fp);
+	}
+#endif
+
 	AZ(close(child_fds[1]));
 	child_fds[1] = -1;

-cs



More information about the varnish-misc mailing list