Start the currently built configuration inside the given rancher stack

@param string $directory
@param string $stackName
@param array $serviceNames only start a certain service
@param bool $upgrade
@param bool $forcedUpgrade
175747
public function start(string $directory, string $stackName, array $serviceNames = null, bool $upgrade = false, bool $forcedUpgrade = false) {
		if($serviceNames === null)
			$serviceNames = [];
		if( !is_array($serviceNames) )
			$serviceNames = [$serviceNames];

		$url = $this->getUrl();
		$account = $this->account;
		if ($this->cliMode && $account instanceof RancherCliAccount)
            $command = [
                $account->getCliVersion(),
                'up',
                "-f",
                "$directory/docker-compose.yml",
                '--rancher-file',
                "$directory/rancher-compose.yml",
                '-s',
                $stackName,
                '-d',
                '-p'
            ];
		else
            $command = [
                $account->getRancherCompose(),
                "-f",
                "$directory/docker-compose.yml",
                '-r',
                "$directory/rancher-compose.yml",
                '-p',
                $stackName,
                'up',
                '-d',
                '-p'
            ];

		if($upgrade)
			$command = array_merge($command, ['--upgrade']);

		if($forcedUpgrade)
			$command = array_merge($command, ['--force-upgrade']);

		$command = array_merge($command, $serviceNames);

		$process = ProcessBuilder::create( $command )
			->setTimeout(null)
			->addEnvironmentVariables([
				'RANCHER_URL' => $url,
				'RANCHER_ACCESS_KEY' => $this->account->getKey(),
				'RANCHER_SECRET_KEY' => $this->account->getSecret(),
			])->getProcess();

		$ran = $this->processHelper->run($this->output, $process, null, null, OutputInterface::VERBOSITY_NORMAL);
		if( $ran->getExitCode() != 0 )
			throw new StartFailedException("Command ".$ran->getCommandLine());
	}
1343072
@Override
    protected void doStart() {
        try {
            String build = _configuration.getValue(SystemConfiguration.Property.BUILD);
            String version = _configuration.getValue(SystemConfiguration.Property.VERSION);
            String year = new SimpleDateFormat("yyyy").format(new Date());

            _log.info("Argus version {} build {}.", version, build);
            _log.info("Copyright Salesforce.com, {}.", year);
            _log.info("{} started.", getName());
            _persistService.start();
            _serviceFactory.getUserService().findAdminUser();
            _serviceFactory.getUserService().findDefaultUser();
        } catch (Throwable ex) {
            _log.error(getName() + " startup aborted.", ex);
        } finally {
            _mergeServiceConfiguration();
            _mergeNotifierConfiguration();
            _log.info(_configuration.toString());
        }
    }
1254005
public function yieldServices(array $serviceNames, array $classNames, bool $includeSubclasses = true, bool $forceClassDetection = true) {

        $matchClass = function($className) use ($includeSubclasses, $classNames) {
            if(in_array($className, $classNames))
                return true;
            if($includeSubclasses) {
                foreach($classNames as $cn) {
                    if(is_subclass_of($className, $cn))
                        return true;
                }
            }
            return false;
        };

        /**
         * @var string $serviceName
         * @var ContainerInterface $container
         */
        foreach($this->serviceData as $serviceName => $container) {
            if(in_array($serviceName, $serviceNames) || $matchClass($this->getServiceClass($serviceName, $forceClassDetection))) {
                yield $serviceName => new ServicePromise(function() use($container) {return $container->getInstance();});
            }
        }
    }
1161859
private function updateStacks()
    {
        $cloudFormation = $this->getService();

        try {
            $this->log('Update stacks...');
            $cloudFormation->updateStack($this->stackProperties());
        } catch (CloudFormationException $e) {
            if (1 === preg_match('/No updates are to be performed/i', $e->getMessage())) {
                $this->log('No updates are to be performed.');
                return;
            }

            throw new \BuildException("AwsErrorCode [{$e->getAwsErrorCode()}] Message : " . $e->getMessage());
        }
    }
64353
public function buildPackageCmd(ServiceDefinition $serviceDefinition, $outputDir, $isDevFabric)
    {
        $args = array(
            $this->getAzureSdkBinaryFolder() . 'cspack.exe',
            $serviceDefinition->getPath()
        );
        foreach ($serviceDefinition->getWebRoleNames() as $roleName) {
            $args[] = $this->getRoleArgument($roleName, $serviceDefinition);
        }
        foreach ($serviceDefinition->getWorkerRoleNames() as $roleName) {
            $args[] = $this->getRoleArgument($roleName, $serviceDefinition);
        }
        $args[] = sprintf('/out:%s', $outputDir);
        
        if ($isDevFabric) {
            $args[] = '/copyOnly';
        }
        
        return $args;
    }
712137
public function startStack($name, $content = null)
    {
        if (is_null($content)) {
            ob_start();
        }

        $this->stacks[] = $name;
        
        $this->pushes[$name] = $content;
    }
833226
private function configureFlysystem($opt, $adapter, $serviceName)
    {
        switch ($adapter) {
            case 'local':
                $filesystem = new Filesystem(new Local($opt['local']['path']));

                break;
            case 'ftp':
                $settings = array(
                    'host'     => $opt['ftp']['host'],
                    'username' => $opt['ftp']['username'],
                    'password' => $opt['ftp']['password'],

                    /* optional config settings */
                    'port'          => $opt['ftp']['port'],
                    'root'          => $opt['ftp']['root'],
                    'passive'       => $opt['ftp']['passive'],
                    'ssl'           => $opt['ftp']['ssl'],
                    'timeout'       => $opt['ftp']['timeout'],
                    'directoryPerm' => $opt['ftp']['directoryPerm'],
                );
                $filesystem = new Filesystem(new Ftp($settings));

                break;
            case 'sftp':
                $settings = array(
                  'host'       => $opt['sftp']['host'],
                  'port'       => $opt['sftp']['port'],
                  'username'   => $opt['sftp']['username'],
                  'password'   => $opt['sftp']['password'],
                  'privateKey' => $opt['sftp']['privateKey'],
                  'root'       => $opt['sftp']['root'],
                  'timeout'    => $opt['sftp']['timeout'],
                );
                $filesystem = new Filesystem(new SftpAdapter($settings));

                break;
            case 'azure':
                $client = BlobRestProxy::createBlobService(
                    sprintf('DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s;', $opt['azure']['account_name'], $opt['azure']['account_key'])
                );
                $adapter    = new AzureBlobStorageAdapter($client, $opt['azure']['container_name']);
                $filesystem = new Filesystem($adapter);

                break;
            case 'aws_s3_v2':
                $options = array(
                    'key'     => $opt['aws_s3_v2']['key'],
                    'secret'  => $opt['aws_s3_v2']['secret'],
                    'region'  => $opt['aws_s3_v2']['region'],
                );
                if (isset($opt['aws_s3_v2']['base_url']) && $opt['aws_s3_v2']['base_url']) {
                    $options['base_url'] = $opt['aws_s3_v2']['base_url'];
                }
                $client     = S3Client::factory($options);
                $filesystem = new Filesystem(new AwsS3v2($client, $opt['aws_s3_v2']['bucket_name'], $opt['aws_s3_v2']['optional_prefix']));

                break;
            case 'aws_s3_v3':
                $client = new S3Client(array(
                    'credentials' => array(
                        'key'     => $opt['aws_s3_v3']['key'],
                        'secret'  => $opt['aws_s3_v3']['secret'],
                    ),
                    'region'  => $opt['aws_s3_v3']['region'],
                    'version' => $opt['aws_s3_v3']['version'],
                ));
                $filesystem = new Filesystem(new AwsS3v3($client, $opt['aws_s3_v3']['bucket_name'], $opt['aws_s3_v3']['optional_prefix']));

                break;
            case 'copy_com':
                $client = new API(
                    $opt['copy_com']['consumer_key'],
                    $opt['copy_com']['consumer_secret'],
                    $opt['copy_com']['access_token'],
                    $opt['copy_com']['token_secret']
                );
                $filesystem = new Filesystem(new CopyAdapter($client, $opt['copy_com']['optional_prefix']));

                break;
            case 'gridfs':
                $mongoClient = new MongoClient();
                $gridFs      = $mongoClient->selectDB($opt['gridfs']['db_name'])->getGridFS();
                $filesystem  = new Filesystem(new GridFSAdapter($gridFs));

                break;
            case 'zip':
                $filesystem = new Filesystem(new ZipArchiveAdapter($opt['zip']['path']));

                break;
            case 'dropbox':
                $filesystem = new Filesystem(new DropboxAdapter(new Client($opt['dropbox']['token'])));

                break;
            case 'rackspace':
                $client = new Rackspace(Rackspace::$opt['rackspace']['endpoint'], array(
                    'username' => $opt['rackspace']['username'],
                    'apiKey'   => $opt['rackspace']['apikey'],
                ));
                $store      = $client->objectStoreService('cloudFiles', $opt['rackspace']['region']);
                $container  = $store->getContainer($opt['rackspace']['container']);
                $filesystem = new Filesystem(new RackspaceAdapter($container));

                break;
            case 'custom':
                $adapter = $this->container->get($serviceName);
                if (is_object($adapter) && $adapter instanceof AdapterInterface) {
                    $filesystem = new Filesystem($adapter);
                }

                break;
        }

        return $filesystem;
    }
496569
private void doUpgrade(List<StorageDirectory> sds,
                 List<StorageInfo> sdsInfo,
                 final NamespaceInfo nsInfo
                 ) throws IOException {
    assert sds.size() == sdsInfo.size();
    UpgradeThread[] upgradeThreads = new UpgradeThread[sds.size()];
    // start to upgrade
    for (int i=0; i<upgradeThreads.length; i++) {
      final StorageDirectory sd = sds.get(i);
      final StorageInfo si = sdsInfo.get(i);
      UpgradeThread thread = new UpgradeThread(sd, si, nsInfo);
      thread.start();
      upgradeThreads[i] = thread;
    }
    // wait for upgrade to be done
    for (UpgradeThread thread : upgradeThreads) {
      try {
        thread.join();
      } catch (InterruptedException e) {
        throw (InterruptedIOException)new InterruptedIOException().initCause(e);
      }
    }
    // check for errors
    for (UpgradeThread thread : upgradeThreads) {
      if (thread.error != null)
        throw new IOException(thread.error);
    }

    // write version file
    this.layoutVersion = FSConstants.LAYOUT_VERSION;
    assert this.namespaceID == nsInfo.getNamespaceID() :
      "Data-node and name-node layout versions must be the same.";
    this.cTime = nsInfo.getCTime();
    for (StorageDirectory sd :sds) {
      sd.write();
      File prevDir = sd.getPreviousDir();
      File tmpDir = sd.getPreviousTmp();
      // rename tmp to previous
      rename(tmpDir, prevDir);
      LOG.info("Upgrade of " + sd.getRoot()+ " is complete.");
    }
  }
226081
@Reference(service = ServerStarted.class,
               policy = ReferencePolicy.DYNAMIC,
               cardinality = ReferenceCardinality.OPTIONAL,
               policyOption = ReferencePolicyOption.GREEDY)
    protected void setServerStarted(ServiceReference<ServerStarted> ref) {

        // We don't want to start the polling task if we haven't been activated yet.

        // Not starting polling if not executing tasks.  Need to coordinate with activate.
        if (readyForPollingTask.addAndCheckIfReady(PollingManager.SERVER_STARTED))
            startPollingTask(configRef.get());
    }
1053057
public function appendService(ServiceBase $successor)
    {
        if ($this->successor !== null) {
            $this->successor->appendService($successor);
        } else {
            $this->successor = $successor;
        }
    }
1192164
public function createInstance(Container $container, ArrayResolver $serviceConfig, $serviceName)
    {
        $activator = $this->getActivator($serviceName, $serviceConfig->resolveStrict('builder'));

        return $activator->createInstance($container, $serviceConfig, $serviceName);
    }
640241
public void goUpDir() throws IOException, ServerException {
        try {
            controlChannel.execute(Command.CDUP);
            // alternative: changeDir("..");
        } catch (FTPReplyParseException rpe) {
            throw ServerException.embedFTPReplyParseException(rpe);
        } catch (UnexpectedReplyCodeException urce) {
            throw ServerException.embedUnexpectedReplyCodeException(
                                urce,
                                "Server refused changing current directory");
        }
    }
1044906
public function startAddon($addonName, $level = 0) {

        $nest = str_repeat(' ', $level);

        $this->log(LogLevel::NOTICE, "{$nest} start addon: {addon}", [
            'addon' => $addonName
        ]);

        // Short circuit if already started
        if ($this->isStarted($addonName)) {
            $this->log(LogLevel::INFO, "{$nest}  already started");
            return true;
        }

        // Check if we've got an addon called this
        $addon = $this->getAddon($addonName);
        if (!$addon) {
            $this->log(LogLevel::WARNING, "{$nest}  unknown addon, not loaded");
            return false;
        }

        // Check requirements
        $requiredAddons = $addon->getInfo('requires') ?? [];

        // If we have requirements, try to load them
        if (count($requiredAddons)) {
            $txtRequirements = implode(',', $requiredAddons);
            $this->log(LogLevel::INFO, "{$nest}  addon has requirements: {requirements}", [
                'requirements' => $txtRequirements
            ]);

            // Check if the requirements are all available
            $missing = [];
            foreach ($requiredAddons as $requiredAddon) {
                if (!$this->isAvailable($requiredAddon)) {
                    $missing[] = $requiredAddon;
                }
            }
            if (count($missing)) {
                $txtMissing = implode(',', $missing);
                $this->log(LogLevel::WARNING, "{$nest}  missing requirements: {missing}", [
                    'missing' => $txtMissing
                ]);
                return false;
            }

            // Keep track of which requirements we've loaded so we can unload if things went wrong
            $startedRequirements = [];

            // Loop over requirements and load each one in turn
            $loadedAllRequirements = true;
            foreach ($requiredAddons as $requiredAddon) {
                if (!$this->isStarted($requiredAddon)) {

                    // Try to load addon if available
                    $loadedRequirement = false;
                    if ($this->isAvailable($requiredAddon)) {
                        $loadedRequirement = $this->startAddon($requiredAddon, $level+1);
                    }

                    $loadedAllRequirements &= $loadedRequirement;

                    if (!$loadedRequirement) {
                        $this->log(LogLevel::WARNING, "{$nest}  failed starting required addon: {addon}", [
                            'addon' => $requiredAddon
                        ]);
                        return false;
                    }

                    $startedRequirements[] = $requiredAddon;
                }
            }
        }

        // Cache autoload info
        $this->autoload = array_merge($this->autoload, $addon->getClasses());

        $addonClass = $addon->getAddonClass();
        if ($addonClass) {

            $this->log(LogLevel::INFO, "{$nest}  creating addon instance: {$addonClass}");

            // Get instance
            $instance = $this->di->getArgs($addonClass, [
                new Reference([AbstractConfig::class, "addons.addon.{$addonName}"])
            ]);
            $instance->setAddon($addon);
            $this->instances[$addonName] = $instance;
            $instance->start();

        }

        $this->enabled[$addonName] = true;

        return true;
    }
1371193
public function filterUpgraderPostInstall($true, $hookExtra, $result) {
        $this->updatePluginData();
        $wasPluginActive = is_plugin_active($this->pluginBaseName);

        global $wp_filesystem;
        $pluginFolder = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . dirname($this->pluginBaseName);
        $wp_filesystem->move($result['destination'], $pluginFolder);
        $result['destination'] = $pluginFolder;
        
        if ($wasPluginActive) {
            $activation = activate_plugin($this->pluginBaseName);
            if (is_wp_error($activation)) {
                throw new \Exception('Unable to reactivate plugin: ' . $activation->get_error_message());
            }
        }
        
        return $result;
    }
771772
public void upgradeTo(String version) throws Exception
    {
    	String installedVersion = systemInfo.getGpVersion();
    	if(!installedVersion.equals(version))
    	{
    		ServerVersionUpgrader upgrader = versionUpgrader(installedVersion, version);
    		upgrader.upgrade(sessionService);
    		
    		String newInstalledVersion = upgrader.upgradedTo() != null ? upgrader.upgradedTo() : version;
    		systemInfo.setGpVersion(newInstalledVersion);
			upgradeTo(version);
    	}
    	
		systDao.store(systemInfo);
    }
394934
public static function init($appDir, array $configFiles)
    {
        self::$loaders = [
            new JsonLoader(),
            new YamlLoader(),
            new PhpLoader()
        ];
        
        self::$appDir = $appDir;
        self::$configFiles = $configFiles;
    }
134001
public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
    {
        $setup->startSetup();
        $eavSetup = $this->eavSetupFactory->create(['setup' => $setup]);

        if (version_compare($context->getVersion(), '1.2.0', '<')) {
            $this->catalogSetup->updateCategorySearchableAttributes($eavSetup);
        }

        if (version_compare($context->getVersion(), '1.2.1', '<')) {
            $this->catalogSetup->updateImageAttribute($eavSetup);
        }

        if (version_compare($context->getVersion(), '1.4.1', '<')) {
            $this->catalogSetup->updateImageAttribute($eavSetup);
        }

        $setup->endSetup();
    }