Commit 52573b54 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add -L option to varnishd, it will:

- enable -d
- set listen address to ($L)
- set telnet address to ($L + 1)
- if no storage configured, use "-smalloc, 1m"
- set -n to /tmp/varnish_L_$L
- set ping_interval to zero

Still missing:  VCC magic to hack backends port number.




git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4777 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 198b4aa8
......@@ -50,6 +50,7 @@ extern struct varnish_stats *VSL_stats;
struct vsb;
extern struct vsb *vident;
int Symbol_Lookup(struct vsb *vsb, void *ptr);
extern unsigned L_arg;
#define TRUST_ME(ptr) ((void*)(uintptr_t)(ptr))
......
......@@ -84,6 +84,7 @@ pid_t mgt_pid;
struct vev_base *mgt_evb;
int exit_status = 0;
struct vsb *vident;
unsigned L_arg = 0;
static void
build_vident(void)
......@@ -423,6 +424,7 @@ main(int argc, char * const *argv)
struct cli cli[1];
struct pidfh *pfh = NULL;
char *dirname;
char tmpbuf[128];
/*
* Start out by closing all unwanted file descriptors we might
......@@ -486,7 +488,7 @@ main(int argc, char * const *argv)
cli_check(cli);
while ((o = getopt(argc, argv,
"a:b:Cdf:Fg:h:i:l:M:n:P:p:S:s:T:t:u:Vx:w:")) != -1)
"a:b:Cdf:Fg:h:i:l:L:M:n:P:p:S:s:T:t:u:Vx:w:")) != -1)
switch (o) {
case 'a':
MCF_ParamSet(cli, "listen_address", optarg);
......@@ -518,6 +520,20 @@ main(int argc, char * const *argv)
break;
case 'l':
l_arg = optarg;
break;
case 'L':
L_arg = strtoul(optarg, NULL, 0);
if (!VIN_L_OK(L_arg)) {
fprintf(stderr, "%s\n", VIN_L_MSG);
exit (1);
}
d_flag++;
n_arg = vin_L_arg(L_arg);
MCF_ParamSet(cli, "ping_interval", "0");
bprintf(tmpbuf, "127.0.0.1:%u", L_arg);
MCF_ParamSet(cli, "listen_address", tmpbuf);
break;
case 'M':
M_arg = optarg;
......@@ -575,6 +591,12 @@ main(int argc, char * const *argv)
argc -= optind;
argv += optind;
if (L_arg) {
/* Learner mode */
if (!s_arg_given)
setup_storage("malloc,1m");
}
if (argc != 0) {
fprintf(stderr, "Too many arguments (%s...)\n", argv[0]);
usage();
......@@ -696,6 +718,10 @@ main(int argc, char * const *argv)
mgt_cli_master(M_arg);
if (T_arg != NULL)
mgt_cli_telnet(T_arg);
else if (L_arg > 0) {
bprintf(tmpbuf, "127.0.0.1:%u", L_arg + 1);
mgt_cli_telnet(tmpbuf);
}
MGT_Run();
......
......@@ -115,5 +115,6 @@ char *vin_L_arg(unsigned L_arg);
#define VIN_L_LOW 1024
#define VIN_L_HIGH 65000
#define VIN_L_OK(a) (a >= VIN_L_LOW && a <= VIN_L_HIGH)
#define VIN_L_MSG "-L argument must be [1024...65000]"
#endif
......@@ -599,8 +599,7 @@ VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
case 'L':
vd->L_opt = strtoul(opt, NULL, 0);
if (vd->L_opt < 1024 || vd->L_opt > 65000) {
fprintf(stderr,
"Illegal -L option must be [1024...65000]\n");
fprintf(stderr, "%s\n", VIN_L_MSG);
exit (1);
}
free(vd->n_opt);
......
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