0
@@ -83,7 +83,6 @@ private:
0
string spawnServerCommand;
0
@@ -155,9 +154,6 @@ private:
0
dup2(STDERR_FILENO, STDOUT_FILENO);
0
- if (!environment.empty()) {
0
- setenv("RAILS_ENV", environment.c_str(), true);
0
dup2(fds[1], SPAWN_SERVER_INPUT_FD);
0
// Close all unnecessary file descriptors
0
@@ -240,10 +236,16 @@ private:
0
* @param appRoot The application root of the application to spawn.
0
* @param lowerPrivilege Whether to lower the application's privileges.
0
* @param lowestUser The user to fallback to if lowering privilege fails.
0
+ * @param environment The RAILS_ENV environment that should be used.
0
* @return An Application smart pointer, representing the spawned application.
0
* @throws SpawnException Something went wrong.
0
- ApplicationPtr sendSpawnCommand(const string &appRoot, bool lowerPrivilege, const string &lowestUser) {
0
+ ApplicationPtr sendSpawnCommand(
0
+ const string &appRoot,
0
+ const string &lowestUser,
0
+ const string &environment
0
@@ -252,6 +254,7 @@ private:
0
(lowerPrivilege) ? "true" : "false",
0
} catch (const SystemException &e) {
0
throw SpawnException(string("Could not write 'spawn_application' "
0
@@ -316,7 +319,8 @@ private:
0
handleSpawnException(const SpawnException &e, const string &appRoot,
0
- bool lowerPrivilege, const string &lowestUser) {
0
+ bool lowerPrivilege, const string &lowestUser,
0
+ const string &environment) {
0
P_DEBUG("Spawn server died. Attempting to restart it...");
0
@@ -331,7 +335,7 @@ private:
0
- return sendSpawnCommand(appRoot, lowerPrivilege, lowestUser
);
0
+ return sendSpawnCommand(appRoot, lowerPrivilege, lowestUser
, environment);
0
throw SpawnException("The spawn server died unexpectedly, and restarting it failed.");
0
@@ -396,9 +400,6 @@ public:
0
* specified, no log file will be used, and the spawn server
0
* will use the same standard output/error channels as the
0
- * @param environment The RAILS_ENV environment that all RoR applications
0
- * should use. If an empty string is specified, the current value
0
- * of the RAILS_ENV environment variable will be used.
0
* @param rubyCommand The Ruby interpreter's command.
0
* @param user The user that the spawn manager should run as. This
0
* parameter only has effect if the current process is
0
@@ -410,12 +411,10 @@ public:
0
SpawnManager(const string &spawnServerCommand,
0
const string &logFile = "",
0
- const string &environment = "production",
0
const string &rubyCommand = "ruby",
0
const string &user = "") {
0
this->spawnServerCommand = spawnServerCommand;
0
this->logFile = logFile;
0
- this->environment = environment;
0
this->rubyCommand = rubyCommand;
0
@@ -470,20 +469,27 @@ public:
0
* but the path does not have to be absolute.
0
* @param lowerPrivilege Whether to lower the application's privileges.
0
* @param lowestUser The user to fallback to if lowering privilege fails.
0
+ * @param environment The RAILS_ENV environment that should be used. May not be empty.
0
* @return A smart pointer to an Application object, which represents the application
0
* instance that has been spawned. Use this object to communicate with the
0
* @throws SpawnException Something went wrong.
0
- ApplicationPtr spawn(const string &appRoot, bool lowerPrivilege = true, const string &lowestUser = "nobody") {
0
+ const string &appRoot,
0
+ bool lowerPrivilege = true,
0
+ const string &lowestUser = "nobody",
0
+ const string &environment = "production"
0
mutex::scoped_lock l(lock);
0
- return sendSpawnCommand(appRoot, lowerPrivilege, lowestUser
);
0
+ return sendSpawnCommand(appRoot, lowerPrivilege, lowestUser
, environment);
0
} catch (const SpawnException &e) {
0
if (e.hasErrorPage()) {
0
- return handleSpawnException(e, appRoot, lowerPrivilege, lowestUser);
0
+ return handleSpawnException(e, appRoot, lowerPrivilege,
0
+ lowestUser, environment);