diff --git a/app.json b/app.json index fe4b84ffd70..053530f04af 100644 --- a/app.json +++ b/app.json @@ -19,7 +19,7 @@ } ], "scripts": { - "postdeploy": "php artisan monica:update --force" + "postdeploy": "php artisan monica:update --force -vvv" }, "env": { "APP_KEY": { diff --git a/app/Console/Commands/Helpers/CommandExecutor.php b/app/Console/Commands/Helpers/CommandExecutor.php index 0208762dbae..a1c9a3cba38 100644 --- a/app/Console/Commands/Helpers/CommandExecutor.php +++ b/app/Console/Commands/Helpers/CommandExecutor.php @@ -37,17 +37,14 @@ public function exec($message, $commandline) public function artisan($message, $commandline, array $arguments = []) { - $this->command->info($message); $info = ''; foreach ($arguments as $key => $value) { - $info = $info.' '.$key.'='.$value; - } - $this->command->line('php artisan '.$commandline.$info); - if ($this->command->getOutput()->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) { - $this->command->call($commandline, $arguments); - } else { - $this->command->callSilent($commandline, $arguments); + if (is_string($key)) { + $info .= ' '.$key.'="'.$value.'"'; + } else { + $info .= ' '.$value; + } } - $this->command->line(''); + $this->exec($message, 'php artisan '.$commandline.$info); } } diff --git a/app/Console/Commands/Update.php b/app/Console/Commands/Update.php index 0fd9be85395..786fa91fdac 100644 --- a/app/Console/Commands/Update.php +++ b/app/Console/Commands/Update.php @@ -60,11 +60,12 @@ public function handle() ]); // Clear or rebuild all cache - if (config('cache.default') != 'database' || Schema::hasTable('cache')) { + if (config('cache.default') != 'database' || Schema::hasTable(config('cache.stores.database.table'))) { $this->commandExecutor->artisan('✓ Resetting application cache', 'cache:clear'); } if ($this->getLaravel()->environment() == 'production') { + $this->commandExecutor->artisan('✓ Clear config cache', 'config:clear'); $this->commandExecutor->artisan('✓ Resetting route cache', 'route:cache'); if ($this->getLaravel()->version() > '5.6') { $this->commandExecutor->artisan('✓ Resetting view cache', 'view:cache'); @@ -86,12 +87,18 @@ public function handle() } if ($this->migrateCollationTest()) { - $this->commandExecutor->artisan('✓ Performing collation migrations', 'migrate:collation', ['--force' => 'true']); + $this->commandExecutor->artisan('✓ Performing collation migrations', 'migrate:collation', ['--force']); } - $this->commandExecutor->artisan('✓ Performing migrations', 'migrate', ['--force' => 'true']); + $this->commandExecutor->artisan('✓ Performing migrations', 'migrate', ['--force']); + + $this->commandExecutor->artisan('✓ Ping for new version', 'monica:ping', ['--force']); - $this->commandExecutor->artisan('✓ Ping for new version', 'monica:ping', ['--force' => 'true']); + // Cache config + if ($this->getLaravel()->environment() == 'production' + && (config('cache.default') != 'database' || Schema::hasTable(config('cache.stores.database.table')))) { + $this->commandExecutor->artisan('✓ Cache configuraton', 'config:cache'); + } } finally { $this->commandExecutor->artisan('✓ Maintenance mode: off', 'up'); } diff --git a/config/trustedproxy.php b/config/trustedproxy.php index 8caa659f786..3a4b6b8b691 100644 --- a/config/trustedproxy.php +++ b/config/trustedproxy.php @@ -44,6 +44,6 @@ /* * Enable cloudflare trusted proxies */ - 'cloudflare' => env('APP_TRUSTED_CLOUDFLARE', false), + 'cloudflare' => (bool) env('APP_TRUSTED_CLOUDFLARE', false), ]; diff --git a/database/migrations/2018_07_08_104306_update-timestamps-timezone.php b/database/migrations/2018_07_08_104306_update-timestamps-timezone.php index 313553899cc..c85d62a71ac 100644 --- a/database/migrations/2018_07_08_104306_update-timestamps-timezone.php +++ b/database/migrations/2018_07_08_104306_update-timestamps-timezone.php @@ -15,7 +15,7 @@ public function up() { $timezone = env('APP_DEFAULT_TIMEZONE', 'UTC'); - if ($timezone == 'UTC') { + if ($timezone == null || $timezone == 'UTC') { return; } diff --git a/docs/installation/generic.md b/docs/installation/generic.md index 1eaa656a9d7..1b479ba4a27 100644 --- a/docs/installation/generic.md +++ b/docs/installation/generic.md @@ -95,6 +95,9 @@ exit 1. Run `php artisan setup:production` to run the migrations, seed the database and symlink folders. 1. Optional: run `php artisan passport:install` to create the access tokens required for the API (Optional). +The `setup:production` command will run migrations scripts for database, and flush all cache for config, route, and view, as an optimization process. +As the configuration of the application is cached, any update on the `.env` file will not be detected after that. You may have to run `php artisan config:cache` manually after every update of `.env` file. + ### 4. Configure cron job Monica requires some background processes to continuously run. The list of things Monica does in the background is described [here](https://github.com/monicahq/monica/blob/master/app/Console/Kernel.php#L33). diff --git a/docs/installation/update.md b/docs/installation/update.md index fbbb4e150f7..7d7e430d625 100644 --- a/docs/installation/update.md +++ b/docs/installation/update.md @@ -27,6 +27,10 @@ steps below to update it, **every single time**, or you will run into problems. php artisan monica:update --force ``` +The `monica:update` command will run migrations scripts for database, and flush all cache for config, route, and view, as an optimization process. +As the configuration of the application is cached, any update on the `.env` file will not be detected after that. You may have to run `php artisan config:cache` manually after every update of `.env` file. + + Your instance should be updated. ## Importing vCards (CLI only) diff --git a/scripts/docker/test-server.sh b/scripts/docker/test-server.sh index f22c0ab02d4..ed6dfb178a6 100755 --- a/scripts/docker/test-server.sh +++ b/scripts/docker/test-server.sh @@ -20,7 +20,7 @@ else fi # Run migrations -${ARTISAN} monica:update --force +${ARTISAN} monica:update --force -v # Run cron crond -b & diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 8bc5c69de4a..3df996e1c8a 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -18,7 +18,7 @@ else fi # Run migrations -${ARTISAN} monica:update --force +${ARTISAN} monica:update --force -v echo -e "\n\n\033[1;32mDone! You can access Monica by visiting \033[4;96mhttp://localhost:8080\033[0;40m\033[1;32m from your host machine\033[0;40m"