in modules/server/mod-eval.hpp [1376:1433]
int postConfig(apr_pool_t *p, unused apr_pool_t *plog, unused apr_pool_t *ptemp, server_rec *s) {
extern const value applyLifecycle(const list<value>&);
const gc_scoped_pool sp(p);
// Get the server configuration and determine the server name
ServerConf& sc = httpd::serverConf<ServerConf>(s, &mod_tuscany_eval);
debug(httpd::serverName(s), "modeval::postConfig::serverName");
debug(sc.contribc.contribPath, "modeval::postConfig::contribPath");
debug(sc.contribc.composName, "modeval::postConfig::composName");
// Count the calls to post config
const string k("tuscany::modeval::postConfig");
const long int count = (long int)httpd::userData(k, s);
httpd::putUserData(k, (void*)(count + 1), s);
// Count == 0, do nothing as post config is always called twice,
// count == 1 is the first start, count > 1 is a restart
if (count == 0)
return OK;
if (count == 1) {
// Chdir to the deployed contribution
if (chdir(c_str(sc.contribc.contribPath)) != 0) {
mkfailure<bool>(string("Couldn't chdir to the deployed contribution: ") + sc.contribc.contribPath);
return -1;
}
debug("modeval::postConfig::start");
const failable<value> r = failableResult(applyLifecycle(mklist<value>("start")));
if (!hasContent(r))
return -1;
debug(content(r), "modeval::postConfig::setlifecycle");
sc.lifecycle = content(r);
}
if (count > 1) {
debug("modeval::postConfig::restart");
const failable<value> r = failableResult(applyLifecycle(mklist<value>("restart")));
if (!hasContent(r))
return -1;
debug(content(r), "modeval::postConfig::setlifecycle");
sc.lifecycle = content(r);
}
// Configure the deployed components
const failable<Composite> compos = confComponents(sc.contribc.contribPath, sc.contribc.composName, nilValue, emptyString, sc.compos.impls, (value)sc.lifecycle, sc.sslc, sc.timeout);
if (!hasContent(compos)) {
cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
return -1;
}
sc.compos = content(compos);
// Register a cleanup callback, called when the server is stopped or restarted
apr_pool_pre_cleanup_register(p, (void*)&sc, serverCleanup);
// Merge the configuration into the virtual hosts
return postConfigMerge(sc, s->next);
}