-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2.x] Adds support for
octane:status
(#115)
* Adds `octane:status` command * Only runs on vapor * Only runs with Octane installed * Update OctaneStatusCommand.php Co-authored-by: Taylor Otwell <taylor@laravel.com>
- Loading branch information
1 parent
7ea7c00
commit fbe8c41
Showing
4 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace Laravel\Vapor\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
|
||
class OctaneStatusCommand extends Command | ||
{ | ||
/** | ||
* The command's signature. | ||
* | ||
* @var string | ||
*/ | ||
public $signature = 'octane:status'; | ||
|
||
/** | ||
* The command's description. | ||
* | ||
* @var string | ||
*/ | ||
public $description = 'Get the current status of the Octane server'; | ||
|
||
/** | ||
* Handle the command. | ||
* | ||
* @return int | ||
*/ | ||
public function handle() | ||
{ | ||
$this->isEnviromentRunningOnOctane() | ||
? $this->info('Octane server is running.') | ||
: $this->info('Octane server is not running.'); | ||
} | ||
|
||
/** | ||
* Determine if the enviroment is running on Octane. | ||
* | ||
* @return bool | ||
*/ | ||
protected function isEnviromentRunningOnOctane() | ||
{ | ||
return isset($_ENV['OCTANE_DATABASE_SESSION_TTL']); | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Laravel\Vapor\Tests\Feature\Commands; | ||
|
||
if (! interface_exists(\Laravel\Octane\Contracts\Client::class)) { | ||
return; | ||
} | ||
|
||
use Laravel\Vapor\Tests\TestCase; | ||
|
||
class OctaneStatusCommandTest extends TestCase | ||
{ | ||
protected function setUp(): void | ||
{ | ||
$_ENV['VAPOR_SSM_PATH'] = 'foo'; | ||
|
||
parent::setUp(); | ||
} | ||
|
||
public function test_when_octane_is_not_running() | ||
{ | ||
$this->artisan('octane:status') | ||
->assertSuccessful() | ||
->expectsOutput('Octane server is not running.'); | ||
} | ||
|
||
public function test_when_octane_is_running() | ||
{ | ||
$_ENV['OCTANE_DATABASE_SESSION_TTL'] = 'false'; | ||
|
||
$this->artisan('octane:status') | ||
->assertSuccessful() | ||
->expectsOutput('Octane server is running.'); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
unset($_ENV['OCTANE_DATABASE_SESSION_TTL']); | ||
unset($_ENV['VAPOR_SSM_PATH']); | ||
|
||
parent::tearDown(); | ||
} | ||
} |
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