	SmartSpawner(const SafeLibevPtr &_libev,
		const ResourceLocator &_resourceLocator,
		const ServerInstanceDir::GenerationPtr &_generation,
		const vector<string> &_preloaderCommand,
		const Options &_options,
		const RandomGeneratorPtr &_randomGenerator = RandomGeneratorPtr(),
		const SpawnerConfigPtr &_config = SpawnerConfigPtr())
		: Spawner(_resourceLocator),
		  libev(_libev),
		  preloaderCommand(_preloaderCommand)
	{
		if (preloaderCommand.size() < 2) {
			throw ArgumentException("preloaderCommand must have at least 2 elements");
		}
		
		generation = _generation;
		options    = _options.copyAndPersist().clearLogger();
		pid        = -1;
		m_lastUsed = SystemTime::getUsec();
		
		preloaderOutputWatcher.set<SmartSpawner, &SmartSpawner::onPreloaderOutputReadable>(this);

		if (_randomGenerator == NULL) {
			randomGenerator = make_shared<RandomGenerator>();
		} else {
			randomGenerator = _randomGenerator;
		}
		if (_config == NULL) {
			config = make_shared<SpawnerConfig>();
		} else {
			config = _config;
		}
	}
	SmartSpawner(const SafeLibevPtr &_libev,
		const ResourceLocator &_resourceLocator,
		const ServerInstanceDir::GenerationPtr &_generation,
		const vector<string> &_preloaderCommand,
		const Options &_options,
		const RandomGeneratorPtr &_randomGenerator = RandomGeneratorPtr(),
		const SpawnerConfigPtr &_config = SpawnerConfigPtr())
		: Spawner(_resourceLocator),
		  libev(_libev),
		  preloaderCommand(_preloaderCommand)
	{
		if (preloaderCommand.size() < 2) {
			throw ArgumentException("preloaderCommand must have at least 2 elements");
		}
		
		generation = _generation;
		options    = _options.copyAndPersist().clearLogger();
		pid        = -1;
		m_lastUsed = SystemTime::getUsec();
		
		preloaderOutputWatcher.set<SmartSpawner, &SmartSpawner::onPreloaderOutputReadable>(this);

		if (_randomGenerator == NULL) {
			randomGenerator = make_shared<RandomGenerator>();
		} else {
			randomGenerator = _randomGenerator;
		}
		if (_config == NULL) {
			config = make_shared<SpawnerConfig>();
		} else {
			config = _config;
		}
	}