r2234 - in branches/1.2: . bin/varnishhist bin/varnishlog bin/varnishncsa bin/varnishstat

des at projects.linpro.no des at projects.linpro.no
Thu Nov 8 22:06:50 CET 2007


Author: des
Date: 2007-11-08 22:06:49 +0100 (Thu, 08 Nov 2007)
New Revision: 2234

Modified:
   branches/1.2/
   branches/1.2/bin/varnishhist/varnishhist.c
   branches/1.2/bin/varnishlog/varnishlog.1
   branches/1.2/bin/varnishlog/varnishlog.c
   branches/1.2/bin/varnishncsa/varnishncsa.1
   branches/1.2/bin/varnishncsa/varnishncsa.c
   branches/1.2/bin/varnishstat/varnishstat.c
Log:
Merged revisions 2229-2231 via svnmerge from 
svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache

........
  r2229 | des | 2007-11-08 17:27:53 +0100 (Thu, 08 Nov 2007) | 2 lines
  
  Pick some nits.
........
  r2230 | des | 2007-11-08 17:28:26 +0100 (Thu, 08 Nov 2007) | 2 lines
  
  Copy&paste -D (daemonize) from varnishlog.
........
  r2231 | des | 2007-11-08 17:52:40 +0100 (Thu, 08 Nov 2007) | 3 lines
  
  Pressing 0-9 will change the delay to the corresponding power of two (e.g.
  press 3 for 2^3 = 8 seconds)
........



Property changes on: branches/1.2
___________________________________________________________________
Name: svnmerge-integrated
   - /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2206,2208,2210-2215,2220,2222-2228
   + /trunk/varnish-cache:1-2101,2104-2107,2115-2120,2122-2130,2133,2151,2153-2154,2157,2161-2162,2166-2168,2173,2175-2176,2180-2184,2186-2193,2206,2208,2210-2215,2220,2222-2231

Modified: branches/1.2/bin/varnishhist/varnishhist.c
===================================================================
--- branches/1.2/bin/varnishhist/varnishhist.c	2007-11-08 21:05:43 UTC (rev 2233)
+++ branches/1.2/bin/varnishhist/varnishhist.c	2007-11-08 21:06:49 UTC (rev 2234)
@@ -279,6 +279,18 @@
 		case 'q':
 			endwin();
 			return;
+		case '0':
+		case '1':
+		case '2':
+		case '3':
+		case '4':
+		case '5':
+		case '6':
+		case '7':
+		case '8':
+		case '9':
+			delay = 1 << (ch - '0');
+			break;
 		default:
 			beep();
 			break;

Modified: branches/1.2/bin/varnishlog/varnishlog.1
===================================================================
--- branches/1.2/bin/varnishlog/varnishlog.1	2007-11-08 21:05:43 UTC (rev 2233)
+++ branches/1.2/bin/varnishlog/varnishlog.1	2007-11-08 21:06:49 UTC (rev 2234)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd June 15, 2007
+.Dd November 8, 2007
 .Dt VARNISHLOG 1
 .Os
 .Sh NAME
@@ -44,9 +44,9 @@
 .Op Fl d
 .Op Fl I Ar regex
 .Op Fl i Ar tag
+.Op Fl n Ar varnish_name
 .Op Fl o
 .Op Fl P Ar file
-.Op Fl n Ar varnish_name
 .Op Fl r Ar file
 .Op Fl V
 .Op Fl w Ar file

Modified: branches/1.2/bin/varnishlog/varnishlog.c
===================================================================
--- branches/1.2/bin/varnishlog/varnishlog.c	2007-11-08 21:05:43 UTC (rev 2233)
+++ branches/1.2/bin/varnishlog/varnishlog.c	2007-11-08 21:06:49 UTC (rev 2234)
@@ -283,9 +283,9 @@
 {
 	int i, c;
 	int a_flag = 0, D_flag = 0, o_flag = 0;
+	const char *n_arg = NULL;
 	const char *P_arg = NULL;
 	const char *w_arg = NULL;
-	const char *n_arg = NULL;
 	struct pidfh *pfh = NULL;
 	struct VSL_data *vd;
 

Modified: branches/1.2/bin/varnishncsa/varnishncsa.1
===================================================================
--- branches/1.2/bin/varnishncsa/varnishncsa.1	2007-11-08 21:05:43 UTC (rev 2233)
+++ branches/1.2/bin/varnishncsa/varnishncsa.1	2007-11-08 21:06:49 UTC (rev 2234)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd June 15, 2007
+.Dd November 8, 2007
 .Dt VARNISHNCSA 1
 .Os
 .Sh NAME
@@ -40,10 +40,12 @@
 .Op Fl b
 .Op Fl C
 .Op Fl c
+.Op Fl D
 .Op Fl d
 .Op Fl I Ar regex
 .Op Fl i Ar tag
 .Op Fl n Ar varnish_name
+.Op Fl P Ar file
 .Op Fl r Ar file
 .Op Fl V
 .Op Fl w Ar file
@@ -82,6 +84,8 @@
 is specified,
 .Nm
 acts as if they both were.
+.It Fl D
+Daemonize.
 .It Fl d
 Process old log entries on startup.
 Normally,
@@ -109,6 +113,9 @@
 If
 .Fl n
 is not specified, the host name is used.
+.It Fl P Ar file
+Write the process's PID to the specified
+.Ar file .
 .It Fl r Ar file
 Read log entries from
 .Ar file

Modified: branches/1.2/bin/varnishncsa/varnishncsa.c
===================================================================
--- branches/1.2/bin/varnishncsa/varnishncsa.c	2007-11-08 21:05:43 UTC (rev 2233)
+++ branches/1.2/bin/varnishncsa/varnishncsa.c	2007-11-08 21:06:49 UTC (rev 2234)
@@ -69,10 +69,16 @@
 #include <unistd.h>
 #include <limits.h>
 
+#ifndef HAVE_DAEMON
+#include "compat/daemon.h"
+#endif
+
+#include "vsb.h"
+#include "vpf.h"
+
 #include "libvarnish.h"
 #include "shmlog.h"
 #include "varnishapi.h"
-#include "vsb.h"
 
 static struct logline {
 	char *df_H;			/* %H, Protocol version */
@@ -434,7 +440,7 @@
 usage(void)
 {
 
-	fprintf(stderr, "usage: varnishncsa %s [-aV] [-n varnish_name] [-w file]\n", VSL_ARGS);
+	fprintf(stderr, "usage: varnishncsa %s [-aDV] [-n varnish_name] [-P file] [-w file]\n", VSL_ARGS);
 	exit(1);
 }
 
@@ -442,15 +448,17 @@
 main(int argc, char *argv[])
 {
 	int i, c;
+	int a_flag = 0, D_flag = 0;
+	const char *n_arg = NULL;
+	const char *P_arg = NULL;
+	const char *w_arg = NULL;
+	struct pidfh *pfh = NULL;
 	struct VSL_data *vd;
-	const char *ofn = NULL;
-	const char *n_arg = NULL;
-	int append = 0;
 	FILE *of;
 
 	vd = VSL_New();
 
-	while ((c = getopt(argc, argv, VSL_ARGS "an:Vw:")) != -1) {
+	while ((c = getopt(argc, argv, VSL_ARGS "aDn:P:Vw:")) != -1) {
 		i = VSL_Arg(vd, c, optarg);
 		if (i < 0)
 			exit (1);
@@ -458,16 +466,22 @@
 			continue;
 		switch (c) {
 		case 'a':
-			append = 1;
+			a_flag = 1;
 			break;
+		case 'D':
+			D_flag = 1;
+			break;
 		case 'n':
 			n_arg = optarg;
 			break;
+		case 'P':
+			P_arg = optarg;
+			break;
 		case 'V':
 			varnish_version("varnishncsa");
 			exit(0);
 		case 'w':
-			ofn = optarg;
+			w_arg = optarg;
 			break;
 		default:
 			if (VSL_Arg(vd, c, optarg) > 0)
@@ -479,22 +493,37 @@
 	if (VSL_OpenLog(vd, n_arg))
 		exit(1);
 
-	if (ofn) {
-		of = open_log(ofn, append);
+	if (P_arg && (pfh = vpf_open(P_arg, 0600, NULL)) == NULL) {
+		perror(P_arg);
+		exit(1);
+	}
+
+	if (D_flag && daemon(0, 0) == -1) {
+		perror("daemon()");
+		if (pfh != NULL)
+			vpf_remove(pfh);
+		exit(1);
+	}
+
+	if (pfh != NULL)
+		vpf_write(pfh);
+
+	if (w_arg) {
+		of = open_log(w_arg, a_flag);
 		signal(SIGHUP, sighup);
 	} else {
-		ofn = "stdout";
+		w_arg = "stdout";
 		of = stdout;
 	}
 
 	while (VSL_Dispatch(vd, h_ncsa, of) == 0) {
 		if (fflush(of) != 0) {
-			perror(ofn);
+			perror(w_arg);
 			exit(1);
 		}
 		if (reopen && of != stdout) {
 			fclose(of);
-			of = open_log(ofn, append);
+			of = open_log(w_arg, a_flag);
 			reopen = 0;
 		}
 	}

Modified: branches/1.2/bin/varnishstat/varnishstat.c
===================================================================
--- branches/1.2/bin/varnishstat/varnishstat.c	2007-11-08 21:05:43 UTC (rev 2233)
+++ branches/1.2/bin/varnishstat/varnishstat.c	2007-11-08 21:06:49 UTC (rev 2234)
@@ -148,6 +148,18 @@
 		case 'q':
 			endwin();
 			exit(0);
+		case '0':
+		case '1':
+		case '2':
+		case '3':
+		case '4':
+		case '5':
+		case '6':
+		case '7':
+		case '8':
+		case '9':
+			delay = 1 << (ch - '0');
+			break;
 		default:
 			beep();
 			break;




More information about the varnish-commit mailing list