alt_host affects log name, prc name, start dir

This commit is contained in:
David Rose 2009-11-20 00:43:30 +00:00
parent 1972536934
commit 426f96e66b
3 changed files with 72 additions and 18 deletions

View File

@ -95,7 +95,6 @@ P3DInstance(P3D_request_ready_func *func,
P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr(); P3DInstanceManager *inst_mgr = P3DInstanceManager::get_global_ptr();
_instance_id = inst_mgr->get_unique_id(); _instance_id = inst_mgr->get_unique_id();
_has_log_basename = false;
_hidden = (_fparams.lookup_token_int("hidden") != 0); _hidden = (_fparams.lookup_token_int("hidden") != 0);
_matches_run_origin = true; _matches_run_origin = true;
_matches_script_origin = false; _matches_script_origin = false;
@ -1695,13 +1694,6 @@ scan_app_desc_file(TiXmlDocument *doc) {
assert(_xpackage == NULL); assert(_xpackage == NULL);
_xpackage = (TiXmlElement *)xpackage->Clone(); _xpackage = (TiXmlElement *)xpackage->Clone();
const char *log_basename = _xpackage->Attribute("log_basename");
_has_log_basename = false;
if (log_basename != NULL) {
_log_basename = log_basename;
_has_log_basename = false;
}
TiXmlElement *xconfig = _xpackage->FirstChildElement("config"); TiXmlElement *xconfig = _xpackage->FirstChildElement("config");
if (xconfig != NULL) { if (xconfig != NULL) {
int hidden = 0; int hidden = 0;
@ -1711,6 +1703,21 @@ scan_app_desc_file(TiXmlDocument *doc) {
} }
} }
const char *log_basename = xconfig->Attribute("log_basename");
if (log_basename != NULL) {
_log_basename = log_basename;
}
const char *prc_name = xconfig->Attribute("prc_name");
if (prc_name != NULL) {
_prc_name = prc_name;
}
const char *start_dir = xconfig->Attribute("start_dir");
if (start_dir != NULL) {
_start_dir = start_dir;
}
const char *run_origin = xconfig->Attribute("run_origin"); const char *run_origin = xconfig->Attribute("run_origin");
if (run_origin != NULL) { if (run_origin != NULL) {
_matches_run_origin = check_matches_origin(run_origin); _matches_run_origin = check_matches_origin(run_origin);

View File

@ -251,7 +251,8 @@ private:
int _instance_id; int _instance_id;
string _session_key; string _session_key;
string _log_basename; string _log_basename;
bool _has_log_basename; string _prc_name;
string _start_dir;
bool _hidden; bool _hidden;
bool _matches_run_origin; bool _matches_run_origin;
bool _matches_script_origin; bool _matches_script_origin;

View File

@ -60,7 +60,6 @@ P3DSession(P3DInstance *inst) {
_keep_user_env = false; _keep_user_env = false;
_failed = false; _failed = false;
_start_dir = inst_mgr->get_root_dir() + "/start";
_p3dpython_one_process = false; _p3dpython_one_process = false;
_p3dpython_started = false; _p3dpython_started = false;
_p3dpython_running = false; _p3dpython_running = false;
@ -703,6 +702,29 @@ start_p3dpython(P3DInstance *inst) {
_keep_user_env = true; _keep_user_env = true;
} }
if (!_keep_user_env) { if (!_keep_user_env) {
_start_dir = inst_mgr->get_root_dir() + "/start";
string start_dir = inst->get_fparams().lookup_token("start_dir");
if (start_dir.empty()) {
start_dir = inst->_start_dir;
if (!start_dir.empty()) {
// If the start_dir is taken from the p3d file (and not from the
// HTML tokens), then we also append the alt_host name to the
// start_dir, so that each alt_host variant will run in a
// different directory.
string alt_host = inst->get_fparams().lookup_token("alt_host");
if (!alt_host.empty()) {
start_dir += "_";
start_dir += alt_host;
}
}
}
if (!start_dir.empty()) {
_start_dir += "/";
_start_dir += start_dir;
}
mkdir_complete(_start_dir, nout); mkdir_complete(_start_dir, nout);
} }
@ -745,6 +767,21 @@ start_p3dpython(P3DInstance *inst) {
string prc_path = prc_root + sep + search_path; string prc_path = prc_root + sep + search_path;
string prc_name = inst->get_fparams().lookup_token("prc_name"); string prc_name = inst->get_fparams().lookup_token("prc_name");
if (prc_name.empty()) {
prc_name = inst->_prc_name;
if (!prc_name.empty()) {
// If the prc_name is taken from the p3d file (and not from the
// HTML tokens), then we also append the alt_host name to the
// prc_name, so that each alt_host variant will run in a
// different directory.
string alt_host = inst->get_fparams().lookup_token("alt_host");
if (!alt_host.empty()) {
prc_name += "_";
prc_name += alt_host;
}
}
}
if (!prc_name.empty()) { if (!prc_name.empty()) {
// Add the prc_name to the path too, even if this directory doesn't // Add the prc_name to the path too, even if this directory doesn't
// actually exist. // actually exist.
@ -945,17 +982,26 @@ start_p3dpython(P3DInstance *inst) {
console_output = true; console_output = true;
} }
// Get the log filename from the p3d_info.xml file. // Get the log filename from the HTML tokens, or from the
string log_basename = inst->_log_basename; // p3d_info.xml file.
bool has_log_basename = inst->_has_log_basename; string log_basename = inst->get_fparams().lookup_token("log_basename");
if (log_basename.empty()) {
log_basename = inst->_log_basename;
// But we also let it be overridden by the tokens. if (!log_basename.empty()) {
if (inst->get_fparams().has_token("log_basename")) { // If the log_basename is taken from the p3d file (and not from
log_basename = inst->get_fparams().lookup_token("log_basename"); // the HTML tokens), then we also append the alt_host name to
has_log_basename = true; // the log_basename, so that each alt_host variant will run in a
// different directory.
string alt_host = inst->get_fparams().lookup_token("alt_host");
if (!alt_host.empty()) {
log_basename += "_";
log_basename += alt_host;
}
}
} }
if (!has_log_basename) { if (log_basename.empty()) {
#ifdef P3D_PLUGIN_LOG_BASENAME3 #ifdef P3D_PLUGIN_LOG_BASENAME3
// No log_basename specified for the app; use the compiled-in // No log_basename specified for the app; use the compiled-in
// default. // default.