Repository: trafficserver Updated Branches: refs/heads/master b90cfa72b -> 74e514a88
[TS-3364]: Allow specifying a -D<config_dir> to verify_config Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/74e514a8 Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/74e514a8 Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/74e514a8 Branch: refs/heads/master Commit: 74e514a8862b06c657543d647ef0a35133eae898 Parents: b90cfa7 Author: Sudheer Vinukonda <[email protected]> Authored: Fri Mar 6 21:47:05 2015 +0000 Committer: Sudheer Vinukonda <[email protected]> Committed: Fri Mar 6 21:47:05 2015 +0000 ---------------------------------------------------------------------- lib/ts/I_Layout.h | 5 +++++ lib/ts/Layout.cc | 10 ++++++++++ proxy/Main.cc | 11 +++++++++++ 3 files changed, 26 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafficserver/blob/74e514a8/lib/ts/I_Layout.h ---------------------------------------------------------------------- diff --git a/lib/ts/I_Layout.h b/lib/ts/I_Layout.h index 7b36dcb..432ed91 100644 --- a/lib/ts/I_Layout.h +++ b/lib/ts/I_Layout.h @@ -65,6 +65,11 @@ struct Layout char *relative(const char *file); /** + update the sysconfdir to a test conf dir + */ + void update_sysconfdir(const char *dir); + + /** Return file path relative to Layout->prefix Store the path to buf. The buf should be large eough to store PATH_NAME_MAX characters http://git-wip-us.apache.org/repos/asf/trafficserver/blob/74e514a8/lib/ts/Layout.cc ---------------------------------------------------------------------- diff --git a/lib/ts/Layout.cc b/lib/ts/Layout.cc index 6ea5103..9a68ec4 100644 --- a/lib/ts/Layout.cc +++ b/lib/ts/Layout.cc @@ -100,6 +100,16 @@ Layout::relative(char *buf, size_t bufsz, const char *file) } } +void +update_sysconfdir(const char *dir) +{ + if (sysconfdir) { + ats_free(sysconfdir); + } + + sysconfdir = ats_strdup(dir); +} + char * Layout::relative_to(const char *dir, const char *file) { http://git-wip-us.apache.org/repos/asf/trafficserver/blob/74e514a8/proxy/Main.cc ---------------------------------------------------------------------- diff --git a/proxy/Main.cc b/proxy/Main.cc index fe0d9fb..3335e08 100644 --- a/proxy/Main.cc +++ b/proxy/Main.cc @@ -143,6 +143,7 @@ char cluster_host[MAXDNAME + 1] = DEFAULT_CLUSTER_HOST; // = DEFAULT_CLUSTER_PORT_NUMBER; static char command_string[512] = ""; +static char conf_dir[512] = ""; int remote_management_flag = DEFAULT_REMOTE_MANAGEMENT_FLAG; static char error_tags[1024] = ""; @@ -201,6 +202,7 @@ static const ArgumentDescription argument_descriptions[] = { {"interval", 'i', "Statistics Interval", "I", &show_statistics, "PROXY_STATS_INTERVAL", NULL}, {"remote_management", 'M', "Remote Management", "T", &remote_management_flag, "PROXY_REMOTE_MANAGEMENT", NULL}, {"command", 'C', "Maintenance Command to Execute", "S511", &command_string, "PROXY_COMMAND_STRING", NULL}, + {"conf_dir", 'D', "config dir to verify", "S511", &conf_dir, "PROXY_SYS_CONFIG_DIR", NULL}, {"clear_hostdb", 'k', "Clear HostDB on Startup", "F", &auto_clear_hostdb_flag, "PROXY_CLEAR_HOSTDB", NULL}, {"clear_cache", 'K', "Clear Cache on Startup", "F", &cacheProcessor.auto_clear_flag, "PROXY_CLEAR_CACHE", NULL}, #if defined(linux) @@ -709,6 +711,11 @@ cmd_verify(char * /* cmd ATS_UNUSED */) // log_rsb to be init'ed Log::init(DEFAULT_REMOTE_MANAGEMENT_FLAG); + if (*conf_dir) { + fprintf(stderr, "NOTE: VERIFY remap config file: %s...\n\n", conf_dir); + Layout::get()->update_sysconfdir(conf_dir); + } + if (!reloadUrlRewrite()) { exitStatus |= (1 << 0); fprintf(stderr, "ERROR: Failed to load remap.config, exitStatus %d\n\n", exitStatus); @@ -1460,6 +1467,10 @@ main(int /* argc ATS_UNUSED */, const char **argv) if ((*command_string) && (cmd_index(command_string) == cmd_index((char*)"verify_config"))) { fprintf (stderr, "\n\n skip lock check for %s \n\n", command_string); } else { + if (*conf_dir) { + fprintf(stderr, "-D option should be used with -Cverify_config\n"); + _exit(0); + } // Ensure only one copy of traffic server is running check_lockfile(); }
