MCPcopy Create free account
hub / github.com/apache/trafficserver / runroot_extra_handling

Function runroot_extra_handling

src/tscore/runroot.cc:104–150  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104static void
105runroot_extra_handling(const char *executable, bool json)
106{
107 std::string path;
108 // 2. check Environment variable
109 char *env_val = getenv("TS_RUNROOT");
110 if (env_val) {
111 path = get_yaml_path(env_val);
112 if (!path.empty()) {
113 runroot_file = path;
114 if (!json) {
115 ink_notice("using the environment variable TS_RUNROOT");
116 }
117 return;
118 } else if (!json) {
119 ink_warning("Unable to access runroot: '%s' from $TS_RUNROOT", env_val);
120 }
121 }
122 // 3. find cwd or parent path of cwd to check
123 char cwd[PATH_MAX] = {0};
124 if (getcwd(cwd, sizeof(cwd)) != nullptr) {
125 path = get_parent_yaml_path(cwd);
126 if (!path.empty()) {
127 runroot_file = path;
128 if (!json) {
129 ink_notice("using cwd as TS_RUNROOT");
130 }
131 return;
132 }
133 }
134 // 4. installed executable
135 char RealBinPath[PATH_MAX] = {0};
136 if ((executable != nullptr) && realpath(executable, RealBinPath) != nullptr) {
137 std::string bindir = RealBinPath;
138 bindir = bindir.substr(0, bindir.find_last_of('/')); // getting the bin dir not executable path
139 path = get_parent_yaml_path(bindir);
140 if (!path.empty()) {
141 runroot_file = path;
142 if (!json) {
143 ink_notice("using the installed dir as TS_RUNROOT");
144 }
145 return;
146 }
147 }
148 // 5. if no runroot use, using default build
149 return;
150}
151
152// This is a temporary approach to handle runroot with migration to ArgParser.
153// When all program use ArgParser, we can remove the runroot_handler below and replace it with this one.

Callers 2

runroot_handlerFunction · 0.85

Calls 6

get_yaml_pathFunction · 0.85
ink_noticeFunction · 0.85
ink_warningFunction · 0.85
get_parent_yaml_pathFunction · 0.85
emptyMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected