Implement fix for console spam when using invalid environment variable values

This commit is contained in:
Dane Everitt 2017-11-23 15:08:35 -06:00
parent 1fcad8d86c
commit d4758efef8
4 changed files with 51 additions and 26 deletions

View file

@ -2,10 +2,10 @@ APP_ENV=production
APP_DEBUG=false APP_DEBUG=false
APP_KEY=SomeRandomString3232RandomString APP_KEY=SomeRandomString3232RandomString
APP_THEME=pterodactyl APP_THEME=pterodactyl
APP_TIMEZONE=UTC APP_TIMEZONE=America/New_York
APP_CLEAR_TASKLOG=720 APP_CLEAR_TASKLOG=720
APP_DELETE_MINUTES=10 APP_DELETE_MINUTES=10
APP_URL=http://yoursite.com/ APP_URL=
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3306 DB_PORT=3306
@ -13,8 +13,8 @@ DB_DATABASE=panel
DB_USERNAME=pterodactyl DB_USERNAME=pterodactyl
DB_PASSWORD= DB_PASSWORD=
CACHE_DRIVER=redis CACHE_DRIVER=
SESSION_DRIVER=database SESSION_DRIVER=
HASHIDS_SALT= HASHIDS_SALT=
HASHIDS_LENGTH=8 HASHIDS_LENGTH=8
@ -25,9 +25,9 @@ MAIL_PORT=2525
MAIL_USERNAME= MAIL_USERNAME=
MAIL_PASSWORD= MAIL_PASSWORD=
MAIL_ENCRYPTION=tls MAIL_ENCRYPTION=tls
MAIL_FROM=you@example.com MAIL_FROM=no-reply@example.com
QUEUE_DRIVER=database QUEUE_DRIVER=
QUEUE_HIGH=high QUEUE_HIGH=high
QUEUE_STANDARD=standard QUEUE_STANDARD=standard
QUEUE_LOW=low QUEUE_LOW=low

View file

@ -3,6 +3,10 @@ This file is a running track of new features and fixes to each version of the pa
This project follows [Semantic Versioning](http://semver.org) guidelines. This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.7.0-beta.3 (Derelict Dermodactylus)
### Fixed
* `[beta.2]` — Fixes a bug that would cause an endless exception message stream in the console when attemping to setup environment settings in certain instances.
## v0.7.0-beta.2 (Derelict Dermodactylus) ## v0.7.0-beta.2 (Derelict Dermodactylus)
### Fixed ### Fixed
* `[beta.1]` — Fixes a CORS header issue due to a wrong API endpoint being provided in the administrative node listing. * `[beta.1]` — Fixes a CORS header issue due to a wrong API endpoint being provided in the administrative node listing.

View file

@ -9,6 +9,7 @@
namespace Pterodactyl\Console\Commands\Environment; namespace Pterodactyl\Console\Commands\Environment;
use DateTimeZone;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Kernel; use Illuminate\Contracts\Console\Kernel;
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait; use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
@ -18,6 +19,25 @@ class AppSettingsCommand extends Command
{ {
use EnvironmentWriterTrait; use EnvironmentWriterTrait;
const ALLOWED_CACHE_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached'
];
const ALLOWED_SESSION_DRIVERS = [
'redis' => 'Redis (recommended)',
'memcached' => 'Memcached',
'database' => 'MySQL Database',
'file' => 'Filesystem',
'cookie' => 'Cookie',
];
const ALLOWED_QUEUE_DRIVERS = [
'redis' => 'Redis (recommended)',
'database' => 'MySQL Database',
'sync' => 'Sync',
];
/** /**
* @var \Illuminate\Contracts\Console\Kernel * @var \Illuminate\Contracts\Console\Kernel
*/ */
@ -37,11 +57,13 @@ class AppSettingsCommand extends Command
* @var string * @var string
*/ */
protected $signature = 'p:environment:setup protected $signature = 'p:environment:setup
{--new-salt : Wether or not to generate a new salt for Hashids.}
{--author= : The email that services created on this instance should be linked to.} {--author= : The email that services created on this instance should be linked to.}
{--url= : The URL that this Panel is running on.} {--url= : The URL that this Panel is running on.}
{--timezone= : The timezone to use for Panel times.} {--timezone= : The timezone to use for Panel times.}
{--cache= : The cache driver backend to use.} {--cache= : The cache driver backend to use.}
{--session= : The session driver backend to use.} {--session= : The session driver backend to use.}
{--queue= : The queue driver backend to use.}
{--redis-host= : Redis host to use for connections.} {--redis-host= : Redis host to use for connections.}
{--redis-pass= : Password used to connect to redis.} {--redis-pass= : Password used to connect to redis.}
{--redis-port= : Port to connect to redis over.}'; {--redis-port= : Port to connect to redis over.}';
@ -72,7 +94,7 @@ class AppSettingsCommand extends Command
*/ */
public function handle() public function handle()
{ {
if (empty($this->config->get('hashids.salt')) || $this->option('--new-salt')) { if (empty($this->config->get('hashids.salt')) || $this->option('new-salt')) {
$this->variables['HASHIDS_SALT'] = str_random(20); $this->variables['HASHIDS_SALT'] = str_random(20);
} }
@ -87,33 +109,31 @@ class AppSettingsCommand extends Command
); );
$this->output->comment(trans('command/messages.environment.app.timezone_help')); $this->output->comment(trans('command/messages.environment.app.timezone_help'));
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->ask( $this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
trans('command/messages.environment.app.timezone'), $this->config->get('app.timezone') trans('command/messages.environment.app.timezone'),
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
$this->config->get('app.timezone')
); );
$selected = $this->config->get('cache.default', 'redis');
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice( $this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
trans('command/messages.environment.app.cache_driver'), [ trans('command/messages.environment.app.cache_driver'),
'redis' => 'Redis (recommended)', self::ALLOWED_CACHE_DRIVERS,
'memcached' => 'Memcached', array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
], $this->config->get('cache.default', 'redis')
); );
$selected = $this->config->get('session.driver', 'redis');
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice( $this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
trans('command/messages.environment.app.session_driver'), [ trans('command/messages.environment.app.session_driver'),
'redis' => 'Redis (recommended)', self::ALLOWED_SESSION_DRIVERS,
'memcached' => 'Memcached', array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
'database' => 'MySQL Database',
'file' => 'Filesystem',
'cookie' => 'Cookie',
], $this->config->get('session.driver', 'redis')
); );
$this->variables['QUEUE_DRIVER'] = $this->option('session') ?? $this->choice( $selected = $this->config->get('queue.default', 'redis');
trans('command/messages.environment.app.session_driver'), [ $this->variables['QUEUE_DRIVER'] = $this->option('queue') ?? $this->choice(
'redis' => 'Redis (recommended)', trans('command/messages.environment.app.queue_driver'),
'database' => 'MySQL Database', self::ALLOWED_QUEUE_DRIVERS,
'sync' => 'Sync', array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
], $this->config->get('queue.driver', 'redis')
); );
$this->checkForRedis(); $this->checkForRedis();

View file

@ -82,6 +82,7 @@ return [
'timezone' => 'Application Timezone', 'timezone' => 'Application Timezone',
'cache_driver' => 'Cache Driver', 'cache_driver' => 'Cache Driver',
'session_driver' => 'Session Driver', 'session_driver' => 'Session Driver',
'queue_driver' => 'Queue Driver',
'using_redis' => 'You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.', 'using_redis' => 'You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.',
'redis_host' => 'Redis Host', 'redis_host' => 'Redis Host',
'redis_password' => 'Redis Password', 'redis_password' => 'Redis Password',