-
-
Save Quiss/80858d7f67d91913f1b6c788864bf59f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream swoole { | |
server 127.0.0.1:8016; # Production octane port | |
server 127.0.0.1:9016 backup; # Deploy octane port | |
} | |
... | |
proxy_pass http://swoole$suffix; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Laravel\Octane\Commands\StartCommand; | |
use Symfony\Component\Console\Input\InputOption; | |
class OctaneStartCommand extends StartCommand | |
{ | |
public function __construct() | |
{ | |
parent::__construct(); | |
$this->getDefinition()->addOption($this->getDeployOption()); | |
} | |
/** | |
* Get the global environment option for the definition. | |
* | |
* @return \Symfony\Component\Console\Input\InputOption | |
*/ | |
protected function getDeployOption(): InputOption | |
{ | |
$message = 'Usage this option for create temp process.'; | |
return new InputOption('--deploy', '-D', InputOption::VALUE_NONE, $message); | |
} | |
/** | |
* Handle the command. | |
* | |
* @return int | |
*/ | |
public function handle() | |
{ | |
if ($this->option('deploy')) { | |
config(['octane.state_file' => storage_path('logs/octane-server-state-deploy.json')]); | |
} | |
return parent::handle(); // TODO: Change the autogenerated stub | |
} | |
/** | |
* Start the Swoole server for Octane. | |
* | |
* @return int | |
*/ | |
protected function startSwooleServer() | |
{ | |
$port = config('octane.worker_port') ?? $this->option('port'); | |
if ($this->option('deploy')) { | |
$port = config('octane.deployment_worker_port'); | |
} | |
return $this->call('octane:swoole', [ | |
'--host' => $this->option('host'), | |
'--port' => $port, | |
'--workers' => $this->option('workers'), | |
'--task-workers' => $this->option('task-workers'), | |
'--max-requests' => $this->option('max-requests'), | |
'--watch' => $this->option('watch'), | |
]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment