Commit 7f9e1e76 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Name VUT global options accordingly

The API is responsible for checking that global options aren't used more
than once, despite it being handled (soon) in individual VUT setups.
parent 4e0c8ae1
......@@ -93,4 +93,4 @@ VUT_OPT_q
VUT_OPT_r
VUT_OPT_t
VSL_OPT_T
VUT_OPT_V
VUT_GLOBAL_OPT_V
......@@ -59,7 +59,7 @@ VSL_OPT_b
VSL_OPT_c
VSL_OPT_C
VUT_OPT_d
VUT_OPT_D
VUT_GLOBAL_OPT_D
VUT_OPT_g
VUT_OPT_h
VSL_OPT_i
......@@ -67,13 +67,13 @@ VSL_OPT_I
VUT_OPT_k
VSL_OPT_L
VUT_OPT_n
VUT_OPT_P
VUT_GLOBAL_OPT_P
VUT_OPT_q
VUT_OPT_r
VUT_OPT_t
VSL_OPT_T
VSL_OPT_v
VUT_OPT_V
VUT_GLOBAL_OPT_V
LOG_OPT_w
VSL_OPT_x
VSL_OPT_X
......@@ -78,16 +78,16 @@ NCSA_OPT_b
NCSA_OPT_c
VSL_OPT_C
VUT_OPT_d
VUT_OPT_D
VUT_GLOBAL_OPT_D
NCSA_OPT_F
NCSA_OPT_f
NCSA_OPT_g
VUT_OPT_h
VSL_OPT_L
VUT_OPT_n
VUT_OPT_P
VUT_GLOBAL_OPT_P
VUT_OPT_q
VUT_OPT_r
VUT_OPT_t
VUT_OPT_V
VUT_GLOBAL_OPT_V
NCSA_OPT_w
......@@ -274,9 +274,6 @@ main(int argc, char * const *argv)
case 'l':
f_list = 1;
break;
case 'V':
VCS_Message("varnishstat");
exit(0);
case 'x':
xml = 1;
break;
......@@ -286,6 +283,9 @@ main(int argc, char * const *argv)
case 'f':
AN(VSC_Arg(vsc, opt, optarg));
break;
case 'V':
AN(VUT_Arg(opt, optarg));
break;
default:
i = VSM_Arg(vd, opt, optarg);
if (i < 0)
......
......@@ -65,5 +65,5 @@ STAT_OPT_j
STAT_OPT_l
VUT_OPT_n
VUT_OPT_t
VUT_OPT_V
VUT_GLOBAL_OPT_V
STAT_OPT_x
......@@ -72,4 +72,4 @@ VUT_OPT_t
VSL_OPT_T
VSL_OPT_x
VSL_OPT_X
VUT_OPT_V
VUT_GLOBAL_OPT_V
......@@ -51,7 +51,6 @@ struct VUT {
struct VSL_data *vsl;
struct vsm *vsm;
struct VSLQ *vslq;
struct vpf_fh *pfh;
int sighup;
int sigint;
int sigusr1;
......
......@@ -29,16 +29,26 @@
/* VUT options */
#define VUT_GLOBAL_OPT_D \
VOPT("D", "[-D]", "Daemonize", \
"Daemonize." \
)
#define VUT_GLOBAL_OPT_P \
VOPT("P:", "[-P <file>]", "PID file", \
"Write the process' PID to the specified file." \
)
#define VUT_GLOBAL_OPT_V \
VOPT("V", "[-V]", "Version", \
"Print version information and exit." \
)
#define VUT_OPT_d \
VOPT("d", "[-d]", "Process old log entries and exit", \
"Process log records at the head of the log and exit." \
)
#define VUT_OPT_D \
VOPT("D", "[-D]", "Daemonize", \
"Daemonize." \
)
#define VUT_OPT_g \
VOPT("g:", "[-g <session|request|vxid|raw>]", "Grouping mode (default: vxid)", \
"The grouping of the log records. The default is to group" \
......@@ -63,11 +73,6 @@
" the host name is used." \
)
#define VUT_OPT_P \
VOPT("P:", "[-P <file>]", "PID file", \
"Write the process' PID to the specified file." \
)
#define VUT_OPT_q \
VOPT("q:", "[-q <query>]", "VSL query", \
"Specifies the VSL query to use." \
......@@ -90,8 +95,3 @@
" indefinetely for the Varnish instance to appear. " \
" Defaults to 5 seconds." \
)
#define VUT_OPT_V \
VOPT("V", "[-V]", "Version", \
"Print version information and exit." \
)
......@@ -61,12 +61,24 @@ struct VUT VUT;
static int vut_synopsis(const struct vopt_spec *);
static int vut_options(const struct vopt_spec *);
static struct vpf_fh *pfh;
static unsigned daemonized;
static int
vut_daemon(void)
{
if (daemonized)
VUT_Error(1, "Already running as a daemon");
daemonized = 1;
return (varnish_daemon(0, 0));
}
static void
vut_vpf_remove(void)
{
if (VUT.pfh) {
AZ(VPF_Remove(VUT.pfh));
VUT.pfh = NULL;
if (pfh != NULL) {
AZ(VPF_Remove(pfh));
pfh = NULL;
}
}
......@@ -250,19 +262,21 @@ VUT_Setup(void)
/* Open PID file */
if (VUT.P_arg) {
AZ(VUT.pfh);
VUT.pfh = VPF_Open(VUT.P_arg, 0644, NULL);
if (VUT.pfh == NULL)
if (pfh != NULL)
VUT_Error(1, "PID file already created");
pfh = VPF_Open(VUT.P_arg, 0644, NULL);
if (pfh == NULL)
VUT_Error(1, "%s: %s", VUT.P_arg, strerror(errno));
}
/* Daemon mode */
if (VUT.D_opt && varnish_daemon(0, 0) == -1)
if (VUT.D_opt && vut_daemon() == -1)
VUT_Error(1, "Daemon mode: %s", strerror(errno));
/* Write PID and setup exit handler */
if (VUT.pfh != NULL) {
AZ(VPF_Write(VUT.pfh));
if (VUT.P_arg) {
AN(pfh);
AZ(VPF_Write(pfh));
AZ(atexit(vut_vpf_remove));
}
}
......@@ -279,7 +293,7 @@ VUT_Fini(void)
free(VUT.t_arg);
vut_vpf_remove();
AZ(VUT.pfh);
AZ(pfh);
if (VUT.vslq)
VSLQ_Delete(&VUT.vslq);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment