unify -r/-R and -w/-W options into single options

Change-Id: I14672466cc2d9f0024d99d41dd63ec15aecbb58a
changes/96/4596/1
Richard Fuchs 9 years ago
parent d8e1e9f86a
commit 3f1ae98379

@ -168,10 +168,8 @@ option and which are reproduced below:
-f, --foreground Don't fork to background -f, --foreground Don't fork to background
-m, --port-min=INT Lowest port to use for RTP -m, --port-min=INT Lowest port to use for RTP
-M, --port-max=INT Highest port to use for RTP -M, --port-max=INT Highest port to use for RTP
-r, --redis=IP:PORT Connect to Redis database -r, --redis=IP:PORT/INT Connect to Redis database
-R, --redis-db=INT Which Redis DB to use -w, --redis-write=IP:PORT/INT Connect to Redis write database
-w, --redis-write=IP:PORT Connect to Redis write database
-W, --redis-write-db=INT Which Redis write DB to use
-b, --b2b-url=STRING XMLRPC URL of B2B UA -b, --b2b-url=STRING XMLRPC URL of B2B UA
-L, --log-level=INT Mask log priorities above this level -L, --log-level=INT Mask log priorities above this level
--log-facility=daemon|local0|... Syslog facility to use for logging --log-facility=daemon|local0|... Syslog facility to use for logging
@ -354,10 +352,13 @@ The options are described in more detail below.
Delete the call from memory after the specified delay from memory. Can be set to zero for Delete the call from memory after the specified delay from memory. Can be set to zero for
immediate call deletion. immediate call deletion.
* -r, --redis, -R, --redis-db * -r, --redis
Connect to specified Redis database (with the given database number) and use it for persistence Connect to specified Redis database (with the given database number) and use it for persistence
storage. On startup, *rtpengine* will read the contents of this database and restore all calls storage. The format of this option is `ADDRESS:PORT/DBNUM`, for example `127.0.0.1:6379/12`
to connect to the Redis DB number 12 running on localhost on the default Redis port.
On startup, *rtpengine* will read the contents of this database and restore all calls
stored therein. During runtime operation, *rtpengine* will continually update the database's stored therein. During runtime operation, *rtpengine* will continually update the database's
contents to keep it current, so that in case of a service disruption, the last state can be restored contents to keep it current, so that in case of a service disruption, the last state can be restored
upon a restart. upon a restart.
@ -365,7 +366,7 @@ The options are described in more detail below.
When this option is given, *rtpengine* will delay startup until the Redis database adopts the When this option is given, *rtpengine* will delay startup until the Redis database adopts the
master role (but see below). master role (but see below).
* -w, --redis-write, -W, --redis-write-db * -w, --redis-write
Configures a second Redis database for write operations. If this option is given in addition to the Configures a second Redis database for write operations. If this option is given in addition to the
first one, then the first database will be used for read operations (i.e. to restore calls from) while first one, then the first database will be used for read operations (i.e. to restore calls from) while

@ -215,6 +215,30 @@ static struct intf_config *if_addr_parse(char *s) {
static int redis_ep_parse(endpoint_t *ep, int *db, char *str) {
char *sl;
long l;
sl = strchr(str, '/');
if (!sl)
return -1;
*sl = 0;
sl++;
if (!*sl)
return -1;
l = strtol(sl, &sl, 10);
if (*sl != 0)
return -1;
if (l < 0)
return -1;
*db = l;
if (endpoint_parse_any(ep, str))
return -1;
return 0;
}
static void options(int *argc, char ***argv) { static void options(int *argc, char ***argv) {
char **if_a = NULL; char **if_a = NULL;
char **iter; char **iter;
@ -252,10 +276,8 @@ static void options(int *argc, char ***argv) {
{ "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Don't fork to background", NULL }, { "foreground", 'f', 0, G_OPTION_ARG_NONE, &foreground, "Don't fork to background", NULL },
{ "port-min", 'm', 0, G_OPTION_ARG_INT, &port_min, "Lowest port to use for RTP", "INT" }, { "port-min", 'm', 0, G_OPTION_ARG_INT, &port_min, "Lowest port to use for RTP", "INT" },
{ "port-max", 'M', 0, G_OPTION_ARG_INT, &port_max, "Highest port to use for RTP", "INT" }, { "port-max", 'M', 0, G_OPTION_ARG_INT, &port_max, "Highest port to use for RTP", "INT" },
{ "redis", 'r', 0, G_OPTION_ARG_STRING, &redisps, "Connect to Redis database", "IP:PORT" }, { "redis", 'r', 0, G_OPTION_ARG_STRING, &redisps, "Connect to Redis database", "IP:PORT/INT" },
{ "redis-db", 'R', 0, G_OPTION_ARG_INT, &redis_db, "Which Redis DB to use", "INT" }, { "redis-write",'w', 0, G_OPTION_ARG_STRING, &redisps_write, "Connect to Redis write database", "IP:PORT/INT" },
{ "redis-write",'w', 0, G_OPTION_ARG_STRING, &redisps_write, "Connect to Redis write database", "IP:PORT" },
{ "redis-write-db", 'W', 0, G_OPTION_ARG_INT, &redis_write_db,"Which Redis write DB to use", "INT" },
{ "b2b-url", 'b', 0, G_OPTION_ARG_STRING, &b2b_url, "XMLRPC URL of B2B UA" , "STRING" }, { "b2b-url", 'b', 0, G_OPTION_ARG_STRING, &b2b_url, "XMLRPC URL of B2B UA" , "STRING" },
{ "log-level", 'L', 0, G_OPTION_ARG_INT, (void *)&log_level,"Mask log priorities above this level","INT" }, { "log-level", 'L', 0, G_OPTION_ARG_INT, (void *)&log_level,"Mask log priorities above this level","INT" },
{ "log-facility",0, 0, G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"}, { "log-facility",0, 0, G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"},
@ -326,19 +348,13 @@ static void options(int *argc, char ***argv) {
if (silent_timeout <= 0) if (silent_timeout <= 0)
silent_timeout = 3600; silent_timeout = 3600;
if (redisps) { if (redisps)
if (endpoint_parse_any(&redis_ep, redisps)) if (redis_ep_parse(&redis_ep, &redis_db, redisps))
die("Invalid IP or port (--redis)"); die("Invalid Redis endpoint [IP:PORT/INT] (--redis)");
if (redis_db < 0)
die("Must specify Redis DB number (--redis-db) when using Redis");
}
if (redisps_write) { if (redisps_write)
if (endpoint_parse_any(&redis_write_ep, redisps_write)) if (redis_ep_parse(&redis_write_ep, &redis_write_db, redisps_write))
die("Invalid Redis write IP or port (--redis-write)"); die("Invalid Redis endpoint [IP:PORT/INT] (--redis-write)");
if (redis_write_db < 0)
die("Must specify Redis write DB number (--redis-write-db) when using Redis");
}
if (xmlrpc_fmt > 1) if (xmlrpc_fmt > 1)
die("Invalid XMLRPC format"); die("Invalid XMLRPC format");
@ -563,19 +579,21 @@ no_kernel:
daemonize(); daemonize();
wpidfile(); wpidfile();
// start redis restore timer if (mc.redis) {
gettimeofday(&redis_start, NULL); // start redis restore timer
gettimeofday(&redis_start, NULL);
// restore // restore
if (redis_restore(ctx->m, mc.redis)) if (redis_restore(ctx->m, mc.redis))
die("Refusing to continue without working Redis database"); die("Refusing to continue without working Redis database");
// stop redis restore timer // stop redis restore timer
gettimeofday(&redis_stop, NULL); gettimeofday(&redis_stop, NULL);
// print redis restore duration // print redis restore duration
redis_diff += timeval_diff(&redis_stop, &redis_start) / 1000.0; redis_diff += timeval_diff(&redis_stop, &redis_start) / 1000.0;
ilog(LOG_INFO, "Redis restore time = %.0lf ms", redis_diff); ilog(LOG_INFO, "Redis restore time = %.0lf ms", redis_diff);
}
gettimeofday(&ctx->m->latest_graphite_interval_start, NULL); gettimeofday(&ctx->m->latest_graphite_interval_start, NULL);

@ -62,10 +62,8 @@ fi
[ -z "$TOS" ] || OPTIONS="$OPTIONS --tos=$TOS" [ -z "$TOS" ] || OPTIONS="$OPTIONS --tos=$TOS"
[ -z "$PORT_MIN" ] || OPTIONS="$OPTIONS --port-min=$PORT_MIN" [ -z "$PORT_MIN" ] || OPTIONS="$OPTIONS --port-min=$PORT_MIN"
[ -z "$PORT_MAX" ] || OPTIONS="$OPTIONS --port-max=$PORT_MAX" [ -z "$PORT_MAX" ] || OPTIONS="$OPTIONS --port-max=$PORT_MAX"
[ -z "$REDIS" ] || OPTIONS="$OPTIONS --redis=$REDIS" [ -z "$REDIS" -o -z "$REDIS_DB" ] || OPTIONS="$OPTIONS --redis=$REDIS/$REDIS_DB"
[ -z "$REDIS_DB" ] || OPTIONS="$OPTIONS --redis-db=$REDIS_DB" [ -z "$REDIS_WRITE" -o -z "$REDIS_WRITE_DB" ] || OPTIONS="$OPTIONS --redis-write=$REDIS_WRITE/$REDIS_WRITE_DB"
[ -z "$REDIS_WRITE" ] || OPTIONS="$OPTIONS --redis-write=$REDIS_WRITE"
[ -z "$REDIS_WRITE_DB" ] || OPTIONS="$OPTIONS --redis-write-db=$REDIS_WRITE_DB"
[ -z "$B2B_URL" ] || OPTIONS="$OPTIONS --b2b-url=$B2B_URL" [ -z "$B2B_URL" ] || OPTIONS="$OPTIONS --b2b-url=$B2B_URL"
[ -z "$NO_FALLBACK" -o \( "$NO_FALLBACK" != "1" -a "$NO_FALLBACK" != "yes" \) ] || OPTIONS="$OPTIONS --no-fallback" [ -z "$NO_FALLBACK" -o \( "$NO_FALLBACK" != "1" -a "$NO_FALLBACK" != "yes" \) ] || OPTIONS="$OPTIONS --no-fallback"
OPTIONS="$OPTIONS --table=$TABLE" OPTIONS="$OPTIONS --table=$TABLE"

@ -108,14 +108,9 @@ build_opts() {
OPTS+=" --port-max=$PORT_MAX" OPTS+=" --port-max=$PORT_MAX"
fi fi
if [[ -n "$REDIS" ]] if [[ -n "$REDIS" -a -n "$REDIS_DB" ]]
then then
OPTS+=" --redis=$REDIS" OPTS+=" --redis=$REDIS/$REDIS_DB"
fi
if [[ -n "$REDIS_DB" ]]
then
OPTS+=" --redis-db=$REDIS_DB"
fi fi
if [[ -n "$B2B_URL" ]] if [[ -n "$B2B_URL" ]]

Loading…
Cancel
Save