Commit d282b230 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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.


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2699 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0032bfe5
......@@ -59,6 +59,7 @@ void MCF_ParamSet(struct cli *, const char *param, const char *val);
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"
......
......@@ -438,7 +438,9 @@ mgt_run(int dflag, const char *T_arg)
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 @@ mcf_server_startstop(struct cli *cli, const char * const *av, void *priv)
(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]);
}
......
......@@ -459,6 +459,15 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, int f_fd, int C_flag)
/*--------------------------------------------------------------------*/
int
mgt_has_vcl()
{
return (!VTAILQ_EMPTY(&vclhead));
}
/*--------------------------------------------------------------------*/
int
mgt_push_vcls_and_start(unsigned *status, char **p)
{
......
......@@ -494,10 +494,6 @@ main(int argc, char *argv[])
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 @@ main(int argc, char *argv[])
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);
......
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