예제 #1
0
	HelperAgentWatcher(const ResourceLocator &resourceLocator) {
		if (agentsOptions.get("web_server_type") == "apache") {
			helperAgentFilename = resourceLocator.getAgentsDir() + "/apache2/PassengerHelperAgent";
		} else {
			helperAgentFilename = resourceLocator.getAgentsDir() + "/nginx/PassengerHelperAgent";
		}
		requestSocketPassword = randomGenerator->generateByteString(REQUEST_SOCKET_PASSWORD_SIZE);
		messageSocketPassword = randomGenerator->generateByteString(MESSAGE_SERVER_MAX_PASSWORD_SIZE);
	}
static string
findUnionStationGatewayCert(const ResourceLocator &locator,
	const string &cert)
{
	if (cert.empty()) {
		return locator.getResourcesDir() + "/union_station_gateway.crt";
	} else if (cert != "-") {
		return cert;
	} else {
		return "";
	}
}
예제 #3
0
	HelperAgentWatcher(const ResourceLocator &resourceLocator) {
		helperAgentFilename = resourceLocator.getAgentsDir() + "/PassengerHelperAgent";

		report
			.set("request_socket_filename",
				agentsOptions.get("request_socket_filename", false,
					generation->getPath() + "/request"))
			.set("request_socket_password",
				agentsOptions.get("request_socket_password", false,
					randomGenerator->generateAsciiString(REQUEST_SOCKET_PASSWORD_SIZE)))
			.set("helper_agent_admin_socket_address",
				agentsOptions.get("helper_agent_admin_socket_address", false,
					"unix:" + generation->getPath() + "/socket"))
			.set("helper_agent_exit_password",
				agentsOptions.get("helper_agent_exit_password", false,
					randomGenerator->generateAsciiString(MESSAGE_SERVER_MAX_PASSWORD_SIZE)));

		params = report;
		params
			.set("logging_agent_address", loggingAgentAddress)
			.set("logging_agent_password", loggingAgentPassword);
	}
예제 #4
0
파일: main.cpp 프로젝트: DanMillward/halley
	void initResourceLocator(Path dataPath, ResourceLocator& locator) override
	{
		locator.addFileSystem(dataPath);
	}
예제 #5
0
	LoggingAgentWatcher(const ResourceLocator &resourceLocator) {
		agentFilename = resourceLocator.getAgentsDir() + "/PassengerLoggingAgent";
	}
예제 #6
0
void
runInternalRubyTool(const ResourceLocator &resourceLocator,
	const string &ruby, const vector<string> &args, int *status,
	SubprocessOutput *output, size_t maxOutputSize)
{
	string locationConfigFileEnv = "PASSENGER_LOCATION_CONFIGURATION_FILE="
		+ resourceLocator.getInstallSpec();
	string fullProgramPath;
	bool isRubyProgram;
	const char *command[
		4 // env, locationConfigEnvFile, ruby, fullProgramPath
		+ (args.size() - 1)
		+ 1 // NULL
	];
	unsigned int i = 0, j;

	if (args[0][0] == '/') {
		fullProgramPath = args[0];
	} else {
		fullProgramPath = resourceLocator.getBinDir() + "/" + args[0];
	}

	// The tool may be a wrapper script, e.g. one generated by Homebrew.
	// If it's a non-Ruby wrapper script then don't invoke it with Ruby.
	FILE *f = fopen(fullProgramPath.c_str(), "r");
	if (f == NULL) {
		throw RuntimeException("Unable to open " + fullProgramPath);
	}
	char line[1024];
	if (fgets(line, sizeof(line), f) == NULL) {
		if (ferror(f) != 0) {
			fclose(f);
			throw RuntimeException("Unable to read " + fullProgramPath);
		} else {
			throw RuntimeException(fullProgramPath + " is empty");
		}
	} else {
		isRubyProgram = strstr(line, "ruby") != NULL;
	}
	fclose(f);

	command[i++] = "env";
	command[i++] = locationConfigFileEnv.c_str();
	if (isRubyProgram) {
		command[i++] = ruby.c_str();
	}
	command[i++] = fullProgramPath.c_str();
	for (j = 1; j < args.size(); j++) {
		command[i++] = args[j].c_str();
	}
	command[i++] = NULL;

	SubprocessInfo info;
	if (output == NULL) {
		runCommand(command, info);
	} else {
		runCommandAndCaptureOutput(command, info, *output, maxOutputSize);
	}
	if (status != NULL) {
		*status = info.status;
	}
}
예제 #7
0
	Server(FileDescriptor feedbackFd,
		pid_t webServerPid, const string &tempDir,
		bool userSwitching, const string &defaultUser, const string &defaultGroup,
		const string &passengerRoot, const string &rubyCommand,
		unsigned int generationNumber, unsigned int maxPoolSize,
		unsigned int maxInstancesPerApp, unsigned int poolIdleTime,
		const VariantMap &options)
		: serverInstanceDir(webServerPid, tempDir, false),
		  resourceLocator(passengerRoot)
	{
		TRACE_POINT();
		string messageSocketPassword;
		string loggingAgentPassword;
		
		this->feedbackFd  = feedbackFd;
		feedbackChannel   = MessageChannel(feedbackFd);
		
		UPDATE_TRACE_POINT();
		messageSocketPassword = Base64::decode(options.get("message_socket_password"));
		loggingAgentPassword  = options.get("logging_agent_password");
		
		generation       = serverInstanceDir.getGeneration(generationNumber);
		accountsDatabase = AccountsDatabase::createDefault(generation,
			userSwitching, defaultUser, defaultGroup);
		accountsDatabase->add("_web_server", messageSocketPassword, false,
			Account::GET | Account::DETACH | Account::SET_PARAMETERS | Account::EXIT);
		messageServer = ptr(new MessageServer(generation->getPath() + "/socket", accountsDatabase));
		
		createFile(generation->getPath() + "/helper_server.pid",
			toString(getpid()), S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
		
		if (geteuid() == 0 && !userSwitching) {
			lowerPrivilege(defaultUser, defaultGroup);
		}
		
		UPDATE_TRACE_POINT();
		analyticsLogger = ptr(new AnalyticsLogger(options.get("logging_agent_address"),
			"logging", loggingAgentPassword));
		
		pool = ptr(new ApplicationPool::Pool(
			resourceLocator.getSpawnServerFilename(), generation,
			accountsDatabase, rubyCommand,
			analyticsLogger,
			options.getInt("log_level"),
			options.get("debug_log_file", false)
		));
		pool->setMax(maxPoolSize);
		pool->setMaxPerApp(maxInstancesPerApp);
		pool->setMaxIdleTime(poolIdleTime);
		
		messageServer->addHandler(ptr(new TimerUpdateHandler(exitTimer)));
		messageServer->addHandler(ptr(new ApplicationPool::Server(pool)));
		messageServer->addHandler(ptr(new BacktracesServer()));
		messageServer->addHandler(ptr(new ExitHandler(exitEvent)));
		
		UPDATE_TRACE_POINT();
		feedbackChannel.write("initialized",
			"",  // Request socket filename; not available in the Apache helper server.
			messageServer->getSocketFilename().c_str(),
			NULL);
		
		prestarterThread = ptr(new oxt::thread(
			boost::bind(prestartWebApps, resourceLocator, options.get("prestart_urls"))
		));
	}
예제 #8
0
파일: Main.cpp 프로젝트: jbpg/passenger
	HelperAgentWatcher(const ResourceLocator &resourceLocator) {
		helperAgentFilename = resourceLocator.getAgentsDir() + "/PassengerHelperAgent";
		requestSocketPassword = randomGenerator->generateByteString(REQUEST_SOCKET_PASSWORD_SIZE);
		messageSocketPassword = randomGenerator->generateByteString(MESSAGE_SERVER_MAX_PASSWORD_SIZE);
	}