Begin a new deployment

@return boolean
190275
protected function startRevertDeploy() {
		$this->Status = 'Started';
		$this->Doing = 'Deployment';
		$this->log("{$this->Title} starting revert deployment");

		// Skip deployment for dry run
		if($this->Pipeline()->DryRun) {
			$this->log("[Skipped] Create DNDeployment");
			$this->write();
			return true;
		}

		// Get old deployment from pipeline
		$pipeline = $this->Pipeline();
		$previous = $pipeline->PreviousDeployment();
		if(empty($previous) || empty($previous->SHA)) {
			$this->log("No available SHA for {$this->Title}");
			$this->markFailed();
			return false;
		}

		// Initialise deployment
		$deployment = DNDeployment::create();
		// Leave the maintenance page up if we are restoring the DB
		$deployment->LeaveMaintenacePage = $this->doRestoreDB();
		$deployment->EnvironmentID = $pipeline->EnvironmentID;
		$deployment->SHA = $previous->SHA;
		$deployment->DeployerID = $pipeline->AuthorID;
		$deployment->write();
		$deployment->start();
		$this->RollbackDeploymentID = $deployment->ID;
		$this->write();

		return true;
	}
242565
public function start()
    {
        if (! $this->checkForFFmpeg() ||
            ! $this->checkForDCA() ||
            ! $this->checkForLibsodium()) {
            return false;
        }

        // temp
        if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
            $this->emit('error', [new \Exception('The voice client does not work on Windows operating systems at the moment.')]);

            return false;
        }

        $this->initSockets();
    }
97452
public function deploy()
    {
        $isFtp = $this->connections->getCurrentConnectionKey()->isFtp();

        $from = $this->on('dummy', function () {
            $this->setupIfNecessary();
            $this->executeTask('CreateRelease');
            $this->executeTask('PrepareRelease');

            return $this->releasesManager->getCurrentReleasePath();
        });

        $to = $isFtp
            ? $this->paths->getFolder()
            : $this->releasesManager->getCurrentReleasePath();

        return $this->onReleaseReady($from, $to);
    }
937198
public function deploy()
    {
        $configs = JsonListener::open(FEnvFcm::get("framework.config.core.config.file"));
        $default = $configs->default_env;
        if ($default == "prod") {
            JsonListener::close(FEnvFcm::get("framework.config.core.config.file"));
            Output::displayAsError("Cannot deployed to production environment : Your(s) app(s) are already deployed");
        }

        $this->getRequirements();

        $configs->default_env = "prod";
        $configs->deployment = new \DateTime();
        JsonListener::put(
            FEnvFcm::get("framework.config.core.config.file"),
            json_encode($configs, JSON_PRETTY_PRINT)
        );
        JsonListener::close(FEnvFcm::get("framework.config.core.config.file"));

        //ASSETS MANAGER
        $asm = new ASM();
        $asm->__render(["commands" => ["assets:clear"], "options" => ["--env=prod", "--noexit"]]);
        $asm->__render(["commands" => ["assets:copy"], "options" => ["--env=prod", "--noexit"]]);

        // CACHE MANAGER
        (new CAM())->__render(["commands" => ["cache:clear"], "options" => ["--env=all", "--noexit"]]);

        // COMPILED MANAGER
        $com = new COM();
        $com->__render(["commands" => ["compiled:clear"], "options" => ["--env=all", "--noexit"]]);

        // Mercure MANAGER
        (new Mercure())->__render(["commands" => ["mercure:build:jsrouting"], "options" => ["--noexit"]]);

        Output::clear();
        CoreManager::setCurrentModule("Deployer Manager");
        Output::displayAsEndSuccess("The deployment process is successful");
    }
729821
public function started()
	{
		// If it doesn't exist or isn't published
		if ($this->isNew())
		{
			return false;
		}

		if ($this->get('publish_up')
		 && $this->get('publish_up') != '0000-00-00 00:00:00'
		 && $this->get('publish_up') > Date::toSql())
		{
			return false;
		}

		return true;
	}
669258
public function main()
    {

        // load the interval we want to scan the directory
        $interval = $this->getInterval();

        // load the configured directory
        $directory = $this->getDirectory();

        // prepare the extensions of the file we want to watch
        $extensionsToWatch = sprintf('{%s}', implode(',', $this->getExtensionsToWatch()));

        // log the configured deployment directory
        $this->getSystemLogger()->info(
            sprintf('Start scanning directory %s for files to be rotated (interval %d)', $directory, $interval)
        );

        // watch the configured directory
        while (true) {
            // clear the filesystem cache
            clearstatcache();

            // iterate over the files to be watched
            foreach (glob($directory . '/*.' . $extensionsToWatch, GLOB_BRACE) as $fileToRotate) {
                // log that we're rotate the file
                $this->getSystemLogger()->debug(
                    sprintf('Query wheter it is necessary to rotate %s', $fileToRotate)
                );

                // handle file rotation
                $this->handle($fileToRotate);

                // cleanup files
                $this->cleanup($fileToRotate);
            }

            // sleep a while
            sleep($interval);
        }
    }
1125270
public function start() {
        switch ($this->state) {
            case self::STATE_NONE:
                $this->state = self::STATE_SHEDULED;
                $this->counter = 1;
                break;
            default:
                $this->counter += 1;
        }
        return true;
    }
299016
protected function startRevertDatabase() {
		// Mark self as creating a snapshot
		$this->Status = 'Started';
		$this->Doing = 'Snapshot';
		$this->log("{$this->Title} reverting database from snapshot");

		// Skip deployment for dry run
		if($this->Pipeline()->DryRun) {
			$this->write();
			$this->log("[Skipped] Create DNDataTransfer restore");
			return true;
		}

		// Get snapshot
		$pipeline = $this->Pipeline();
		$backup = $pipeline->PreviousSnapshot();
		if(empty($backup) || !$backup->exists()) {
			$this->log("No database to revert for {$this->Title}");
			$this->markFailed();
			return false;
		}

		// Create restore job
		$job = DNDataTransfer::create();
		$job->EnvironmentID = $pipeline->EnvironmentID;
		$job->Direction = 'push';
		$job->Mode = 'db';
		$job->DataArchiveID = $backup->DataArchiveID;
		$job->AuthorID = $pipeline->AuthorID;
		$job->EnvironmentID = $pipeline->EnvironmentID;
		$job->write();
		$job->start();

		// Save rollback
		$this->RollbackDatabaseID = $job->ID;
		$this->write();
		return true;
	}
338667
public function startApproval() {
		$this->Status = 'Started';
		$this->log("Starting {$this->Title}...");
		// Determine if we should use delayed notification
		$recipientGroup = 'all';
		if($this->getConfigSetting('RecipientsDelay')) {
			$this->NotifiedGroup = $recipientGroup = 0;
		}
		// Send to selected group
		$this->sendMessage(self::ALERT_REQUEST, $recipientGroup);
		$this->write();
		return true;
	}
844126
public function start()
    {
        $cli = $this->climate();

        $cli->br();
        $cli->bold()->underline()->out('Alter Model\'s Primary Key');
        $cli->br();

        if ($this->dryRun()) {
            $cli->shout('This command does not support --dry-run');
            $cli->br();
            $cli->whisper('Canceled Conversion');

            return $this;
        }

        $objType = $this->argOrInput('target_model');
        $this->setTargetModel($objType);

        $model  = $this->targetModel();
        $source = $model->source();
        $table  = $source->table();

        $cli->comment(sprintf('The "%s" table will be altered.', $table));
        $cli->br();
        $cli->shout('This process is destructive. A backup should be made before proceeding.');
        $cli->br();
        $cli->red()->flank('Analyse your tables before proceeding. Not all fields can or might be affected.', '!');
        $cli->br();

        $input = $cli->confirm('Continue?');
        if ($input->confirmed()) {
            $cli->info('Starting Conversion');
        } else {
            $cli->info('Canceled Conversion');

            return $this;
        }

        $cli->br();

        $dbh = $source->db();
        if (!$dbh) {
            $cli->error(
                'Could not instantiate a database connection.'
            );

            return $this;
        }

        if (!$source->tableExists()) {
            $cli->error(
                sprintf(
                    'The table "%s" does not exist. This script can only alter existing tables.',
                    $table
                )
            );

            return $this;
        }

        $oldKey = $this->oldPrimaryKey();
        $newKey = $this->newPrimaryKey();

        $dbh->query(
            strtr(
                'LOCK TABLES `%table` WRITE',
                [
                    '%table' => $table,
                ]
            )
        );

        $this->prepareProperties($oldKey, $newKey, $oldProp, $newProp);

        if ($newProp->mode() === $oldProp->mode()) {
            $cli->error(
                sprintf(
                    'The ID is already %s. Canceling conversion.',
                    $this->labelFromMode($newProp)
                )
            );
            $dbh->query('UNLOCK TABLES');

            return $this;
        }

        $newField = $this->propertyField($newProp);
        $oldField = $this->propertyField($oldProp);
        $oldField->setExtra('');

        if (!$this->quiet()) {
            $this->describeConversion($newProp, $oldProp);
        }

        $this->convertIdField($newProp, $newField, $oldProp, $oldField);

        $dbh->query('UNLOCK TABLES');

        if (!$this->quiet()) {
            $cli->br();
            $cli->info('Success!');
        }

        return $this;
    }
663641
public function main()
    {

        // load the interval we want to scan the directory
        $interval = $this->getInterval();

        // load the deployment directory
        $directory = $this->getDirectory();

        // log the configured deployment directory
        $this->getSystemLogger()->debug(sprintf('Start watching directory %s', $directory));

        // load the deployment flag
        $deploymentFlag = $this->getDeploymentFlag();

        // wait until the server has been successfully started at least once
        while ($this->getLastSuccessfullyDeployment($deploymentFlag) === 0) {
            $this->getSystemLogger()->debug(sprintf('%s is waiting for first successful deployment ...', __CLASS__));
            sleep($interval);
        }

        // load the initial hash value of the deployment directory
        $oldHash = $this->getDirectoryHash($directory);

        // watch the deployment directory
        while (true) {
            // load the actual hash value for the deployment directory
            $newHash = $this->getDirectoryHash($directory);

            // log the found directory hash value
            $this->getSystemLogger()->debug(sprintf("Comparing directory hash %s (previous) : %s (actual)", $oldHash, $newHash));

            // compare the hash values, if not equal restart the appserver
            if ($oldHash !== $newHash) {
                // log that changes have been found
                $this->getSystemLogger()->debug(sprintf('Found changes in directory %s', $directory));

                // log the UNIX timestamp of the last successful deployment
                $lastSuccessfullDeployment = $this->getLastSuccessfullyDeployment($deploymentFlag);

                // restart the appserver
                $this->restart();

                // wait until deployment has been finished
                while ($lastSuccessfullDeployment == $this->getLastSuccessfullyDeployment($deploymentFlag)) {
                    sleep($interval);
                }

                // set the directory new hash value after successful deployment
                $oldHash = $this->getDirectoryHash($directory);

                // log that the appserver has been restarted successful
                $this->getSystemLogger()->debug('appserver has successfully been restarted');

            } else {
                // if no changes has been found, wait a second
                sleep($interval);
            }
        }
    }
1042305
public function startCheck()
    {
        $masterPool = getInstance()->getAsynPool($this->master);
        if (!$masterPool) {
            $masterPool = new MysqlAsynPool(getInstance()->config, $this->master);
            getInstance()->addAsynPool($this->master, $masterPool, true);
        }

        foreach ($this->slaves as $slavePoolName) {
            $slavePool = getInstance()->getAsynPool($slavePoolName);
            if (!$slavePool) {
                $slavePool = new MysqlAsynPool(getInstance()->config, $slavePoolName);
                getInstance()->addAsynPool($slavePoolName, $slavePool, true);
            }
        }

        return $this;
    }
686517
protected function launchNextTask()
    {
        if (! $this->numberOfThreadsToLaunch) {
            return false;
        }
        
        $taskInfos = $this->pool[$this->numberOfTasks - $this->numberOfThreadsToLaunch];
        
        $taskInfos['task']->fork();
        $this->numberOfRunningThreads++;
        $this->numberOfThreadsToLaunch--;
        
        return true;
    }
621736
public function setup()
	{
		$this->addRule('publish_down', function($data)
		{
			if (!$data['publish_down'] || $data['publish_down'] == '0000-00-00 00:00:00')
			{
				return false;
			}
			return $data['publish_down'] >= $data['publish_up'] ? false : Lang::txt('The entry cannot end before it begins');
		});
	}
789822
public function deploy()
    {
        $this->logger->notice('Deploying ' . $this->name . ' (' . $this->releaseIdentifier . ')');
        $this->workflow->run($this);
    }
1050773
protected function startServer(): void
    {
        $this->guardServerStarting();

        $this->process = new Process($this->prepareCommand());
        $this->process->setWorkingDirectory($this->laravelPublicPath());
        $this->process->start();
    }
110841
public function startCLISession()
    {
        $cm = DI::getInjector()->getInstance(CacheManager::class);
        $this->session_cache = $cm->getCache('cli-session');
        $ref = &$this->session_cache->get();

        $GLOBALS['_SESSION'] = &$ref;

        // Make sure the session variables are available through this object
        $this->values = &$ref;
        $this->set('CLI', true);
        $this->active = true;
        return $this;
    }