ext/common/ApplicationPool2/SpawnerFactory.h in passenger-4.0.45 vs ext/common/ApplicationPool2/SpawnerFactory.h in passenger-4.0.46
- old
+ new
@@ -38,60 +38,50 @@
using namespace oxt;
class SpawnerFactory {
private:
- ResourceLocator resourceLocator;
ServerInstanceDir::GenerationPtr generation;
- RandomGeneratorPtr randomGenerator;
boost::mutex syncher;
SpawnerConfigPtr config;
DummySpawnerPtr dummySpawner;
SpawnerPtr tryCreateSmartSpawner(const Options &options) {
- string dir = resourceLocator.getHelperScriptsDir();
+ string dir = config->resourceLocator.getHelperScriptsDir();
vector<string> preloaderCommand;
if (options.appType == "classic-rails") {
preloaderCommand.push_back(options.ruby);
preloaderCommand.push_back(dir + "/classic-rails-preloader.rb");
} else if (options.appType == "rack") {
preloaderCommand.push_back(options.ruby);
preloaderCommand.push_back(dir + "/rack-preloader.rb");
} else {
return SpawnerPtr();
}
- return boost::make_shared<SmartSpawner>(resourceLocator,
- generation, preloaderCommand, options, config);
+ return boost::make_shared<SmartSpawner>(generation, preloaderCommand,
+ options, config);
}
public:
- SpawnerFactory(const ResourceLocator &_resourceLocator,
- const ServerInstanceDir::GenerationPtr &_generation,
- const SpawnerConfigPtr &_config = SpawnerConfigPtr())
- : resourceLocator(_resourceLocator),
- generation(_generation)
- {
- if (_config == NULL) {
- config = boost::make_shared<SpawnerConfig>();
- } else {
- config = _config;
- }
- }
+ SpawnerFactory(const ServerInstanceDir::GenerationPtr &_generation,
+ const SpawnerConfigPtr &_config)
+ : generation(_generation),
+ config(_config)
+ { }
virtual ~SpawnerFactory() { }
virtual SpawnerPtr create(const Options &options) {
if (options.spawnMethod == "smart" || options.spawnMethod == "smart-lv2") {
SpawnerPtr spawner = tryCreateSmartSpawner(options);
if (spawner == NULL) {
- spawner = boost::make_shared<DirectSpawner>(resourceLocator,
- generation, config);
+ spawner = boost::make_shared<DirectSpawner>(generation, config);
}
return spawner;
} else if (options.spawnMethod == "direct" || options.spawnMethod == "conservative") {
boost::shared_ptr<DirectSpawner> spawner = boost::make_shared<DirectSpawner>(
- resourceLocator, generation, config);
+ generation, config);
return spawner;
} else if (options.spawnMethod == "dummy") {
syscalls::usleep(config->spawnerCreationSleepTime);
return getDummySpawner();
} else {
@@ -105,27 +95,19 @@
* set debugging options on the spawner.
*/
DummySpawnerPtr getDummySpawner() {
boost::lock_guard<boost::mutex> l(syncher);
if (dummySpawner == NULL) {
- dummySpawner = boost::make_shared<DummySpawner>(resourceLocator, config);
+ dummySpawner = boost::make_shared<DummySpawner>(config);
}
return dummySpawner;
}
/**
* All created Spawner objects share the same SpawnerConfig object.
*/
- SpawnerConfigPtr getConfig() const {
+ const SpawnerConfigPtr &getConfig() const {
return config;
- }
-
- RandomGeneratorPtr getRandomGenerator() const {
- return randomGenerator;
- }
-
- const ResourceLocator &getResourceLocator() const {
- return resourceLocator;
}
};
typedef boost::shared_ptr<SpawnerFactory> SpawnerFactoryPtr;