r2699 - trunk/varnish-cache/bin/varnishd
phk at projects.linpro.no
phk at projects.linpro.no
Sun Jun 15 23:25:42 CEST 2008
Author: phk
Date: 2008-06-15 23:25:41 +0200 (Sun, 15 Jun 2008)
New Revision: 2699
Modified:
trunk/varnish-cache/bin/varnishd/mgt.h
trunk/varnish-cache/bin/varnishd/mgt_child.c
trunk/varnish-cache/bin/varnishd/mgt_vcc.c
trunk/varnish-cache/bin/varnishd/varnishd.c
Log:
Allow varnishd to be started with neither -b nor -f, this is useful
where a central facility is used to push VCL's to a number of Varnish
hosts.
Until a VCL is loaded, the child process cannot be started.
Modified: trunk/varnish-cache/bin/varnishd/mgt.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-15 21:11:19 UTC (rev 2698)
+++ trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-15 21:25:41 UTC (rev 2699)
@@ -59,6 +59,7 @@
void mgt_vcc_init(void);
int mgt_vcc_default(const char *bflag, const char *fflag, int f_fd, int Cflag);
int mgt_push_vcls_and_start(unsigned *status, char **p);
+int mgt_has_vcl(void);
extern char *mgt_cc_cmd;
#include "hash_slinger.h"
Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-15 21:11:19 UTC (rev 2698)
+++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-15 21:25:41 UTC (rev 2699)
@@ -438,7 +438,9 @@
printf("rolling(1)...\n");
fprintf(stderr, "rolling(2)...\n");
- if (!dflag)
+ if (!dflag && !mgt_has_vcl())
+ fprintf(stderr, "No VCL loaded yet\n");
+ else if (!dflag)
start_child();
else
fprintf(stderr,
@@ -460,9 +462,14 @@
(void)av;
if (priv != NULL && child_state == CH_RUNNING)
stop_child();
- else if (priv == NULL && child_state == CH_STOPPED)
- start_child();
- else {
+ else if (priv == NULL && child_state == CH_STOPPED) {
+ if (mgt_has_vcl())
+ start_child();
+ else {
+ cli_result(cli, CLIS_CANT);
+ cli_out(cli, "No VCL available");
+ }
+ } else {
cli_result(cli, CLIS_CANT);
cli_out(cli, "Child in state %s", ch_state[child_state]);
}
Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-15 21:11:19 UTC (rev 2698)
+++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-15 21:25:41 UTC (rev 2699)
@@ -460,6 +460,15 @@
/*--------------------------------------------------------------------*/
int
+mgt_has_vcl()
+{
+
+ return (!VTAILQ_EMPTY(&vclhead));
+}
+
+/*--------------------------------------------------------------------*/
+
+int
mgt_push_vcls_and_start(unsigned *status, char **p)
{
struct vclprog *vp;
Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-15 21:11:19 UTC (rev 2698)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-15 21:25:41 UTC (rev 2699)
@@ -494,10 +494,6 @@
fprintf(stderr, "Only one of -b or -f can be specified\n");
usage();
}
- if (b_arg == NULL && f_arg == NULL) {
- fprintf(stderr, "One of -b or -f must be specified\n");
- usage();
- }
if (f_arg != NULL) {
f_fd = open(f_arg, O_RDONLY);
@@ -533,8 +529,9 @@
exit(1);
}
- if (mgt_vcc_default(b_arg, f_arg, f_fd, C_flag))
- exit (2);
+ if (b_arg != NULL || f_arg != NULL)
+ if (mgt_vcc_default(b_arg, f_arg, f_fd, C_flag))
+ exit (2);
if (C_flag)
exit (0);
More information about the varnish-commit
mailing list