	Hooks(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
	    : cstat(1024),
	      agentsStarter(AS_APACHE)
	{
		serverConfig.finalize();
		Passenger::setLogLevel(serverConfig.logLevel);
		if (serverConfig.debugLogFile != NULL) {
			Passenger::setDebugFile(serverConfig.debugLogFile);
		}
		m_hasModRewrite = UNKNOWN;
		m_hasModDir = UNKNOWN;
		m_hasModAutoIndex = UNKNOWN;
		m_hasModXsendfile = UNKNOWN;
		
		P_DEBUG("Initializing Phusion Passenger...");
		ap_add_version_component(pconf, "Phusion_Passenger/" PASSENGER_VERSION);
		
		if (serverConfig.root == NULL) {
			throw ConfigurationException("The 'PassengerRoot' configuration option "
				"is not specified. This option is required, so please specify it. "
				"TIP: The correct value for this option was given to you by "
				"'passenger-install-apache2-module'.");
		}

		VariantMap params;
		params
			.setPid ("web_server_pid", getpid())
			.setUid ("web_server_worker_uid", unixd_config.user_id)
			.setGid ("web_server_worker_gid", unixd_config.group_id)
			.setInt ("log_level", serverConfig.logLevel)
			.set    ("debug_log_file", (serverConfig.debugLogFile == NULL) ? "" : serverConfig.debugLogFile)
			.set    ("temp_dir", serverConfig.tempDir)
			.setBool("user_switching", serverConfig.userSwitching)
			.set    ("default_user", serverConfig.defaultUser)
			.set    ("default_group", serverConfig.defaultGroup)
			.set    ("default_ruby", serverConfig.defaultRuby)
			.setInt ("max_pool_size", serverConfig.maxPoolSize)
			.setInt ("pool_idle_time", serverConfig.poolIdleTime)
			.setInt ("max_instances_per_app", serverConfig.maxInstancesPerApp)
			.set    ("analytics_log_user", serverConfig.analyticsLogUser)
			.set    ("analytics_log_group", serverConfig.analyticsLogGroup)
			.set    ("union_station_gateway_address", serverConfig.unionStationGatewayAddress)
			.setInt ("union_station_gateway_port", serverConfig.unionStationGatewayPort)
			.set    ("union_station_gateway_cert", serverConfig.unionStationGatewayCert)
			.set    ("union_station_proxy_address", serverConfig.unionStationProxyAddress)
			.setStrSet("prestart_urls", serverConfig.prestartURLs);
		
		serverConfig.ctl.addTo(params);

		agentsStarter.start(serverConfig.root, params);
		
		// Store some relevant information in the generation directory.
		string generationPath = agentsStarter.getGeneration()->getPath();
		server_rec *server;
		string configFiles;
		
		#ifdef AP_GET_SERVER_VERSION_DEPRECATED
			createFile(generationPath + "/web_server.txt",
				ap_get_server_description());
		#else
			createFile(generationPath + "/web_server.txt",
				ap_get_server_version());
		#endif
		
		for (server = s; server != NULL; server = server->next) {
			if (server->defn_name != NULL) {
				configFiles.append(server->defn_name);
				configFiles.append(1, '\n');
			}
		}
		createFile(generationPath + "/config_files.txt", configFiles);
	}
	Hooks(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
	    : cstat(1024),
	      agentsStarter(AS_APACHE)
	{
		serverConfig.finalize();
		Passenger::setLogLevel(serverConfig.logLevel);
		if (serverConfig.debugLogFile != NULL) {
			Passenger::setDebugFile(serverConfig.debugLogFile);
		}
		m_hasModRewrite = UNKNOWN;
		m_hasModDir = UNKNOWN;
		m_hasModAutoIndex = UNKNOWN;
		m_hasModXsendfile = UNKNOWN;
		
		P_DEBUG("Initializing Phusion Passenger...");
		ap_add_version_component(pconf, "Phusion_Passenger/" PASSENGER_VERSION);
		
		if (serverConfig.root == NULL) {
			throw ConfigurationException("The 'PassengerRoot' configuration option "
				"is not specified. This option is required, so please specify it. "
				"TIP: The correct value for this option was given to you by "
				"'passenger-install-apache2-module'.");
		}

		VariantMap params;
		params
			.setPid ("web_server_pid", getpid())
			.setUid ("web_server_worker_uid", unixd_config.user_id)
			.setGid ("web_server_worker_gid", unixd_config.group_id)
			.setInt ("log_level", serverConfig.logLevel)
			.set    ("debug_log_file", (serverConfig.debugLogFile == NULL) ? "" : serverConfig.debugLogFile)
			.set    ("temp_dir", serverConfig.tempDir)
			.setBool("user_switching", serverConfig.userSwitching)
			.set    ("default_user", serverConfig.defaultUser)
			.set    ("default_group", serverConfig.defaultGroup)
			.set    ("default_ruby", serverConfig.defaultRuby)
			.setInt ("max_pool_size", serverConfig.maxPoolSize)
			.setInt ("pool_idle_time", serverConfig.poolIdleTime)
			.setInt ("max_instances_per_app", serverConfig.maxInstancesPerApp)
			.set    ("analytics_log_user", serverConfig.analyticsLogUser)
			.set    ("analytics_log_group", serverConfig.analyticsLogGroup)
			.set    ("union_station_gateway_address", serverConfig.unionStationGatewayAddress)
			.setInt ("union_station_gateway_port", serverConfig.unionStationGatewayPort)
			.set    ("union_station_gateway_cert", serverConfig.unionStationGatewayCert)
			.set    ("union_station_proxy_address", serverConfig.unionStationProxyAddress)
			.setStrSet("prestart_urls", serverConfig.prestartURLs);
		
		serverConfig.ctl.addTo(params);

		agentsStarter.start(serverConfig.root, params);
		
		 
		string generationPath = agentsStarter.getGeneration()->getPath();
		server_rec *server;
		string configFiles;
		
		#ifdef AP_GET_SERVER_VERSION_DEPRECATED
			createFile(generationPath + "/web_server.txt",
				ap_get_server_description());
		#else
			createFile(generationPath + "/web_server.txt",
				ap_get_server_version());
		#endif
		
		for (server = s; server != NULL; server = server->next) {
			if (server->defn_name != NULL) {
				configFiles.append(server->defn_name);
				configFiles.append(1, '\n');
			}
		}
		createFile(generationPath + "/config_files.txt", configFiles);
	}