0

A bit of an annoyance Laravel 5.4 gets stuck in maintenance mode when running a script to update codebase. Basically, I am creating a new folder from a git repo, running all the install commands in the new folder, shutting down the current stage before updating the database, then updating a symlink to point the website to the new folder, then bringing up the site...

I can reboot the server or go to the old folder and run php artisan up to get out of maintenance mode. There is no down file in storage in the new folder, and the database has been wiped, so I am pretty lost why Laravel is remembering the old down file.

here is my deploy script for staging:

#!/usr/bin/env bash
f=/var/www/craiglorious.com

DATE=`date +%Y%m%d`
DATEP=$DATE'-StageFromGit'

cd $f
rm -rf $DATEP
git clone https://github.com/iannazzi/craiglorious.git $DATEP
sudo chgrp -R www-data $DATEP
cd $f/$DATEP
git checkout develop
cp $f/env/stag/.env .
composer install
php artisan jwt:secret

npm install
npm run production

sudo chown -R craig:www-data storage
sudo chmod -R ug+w storage
sudo chown -R craig:www-data bootstrap/cache
sudo chmod -R ug+w bootstrap/cache

cd $f/staging
pwd
php artisan down
cd $f/$DATEP
pwd
php artisan zz:dms

cd $f
pwd
rm $f/staging
ln -s $DATEP $f/staging
cd $f/staging
pwd
php artisan up

Any ideas?

EDIT: I think I have the wrong deployment strategy. I probably should be using git.... unsure....

Iannazzi
  • 1,348
  • 2
  • 18
  • 27
  • Given "I can reboot the server or go to the old folder and run php artisan up to get out of maintenance mode" it's probably not a problem with Laravel and instead a problem with the way you're moving your directories as Laravel still believes your old storage directory is the correct one. Have you cleared the cache? If you go to the new directory and run `php artisan tinker` then do `app()->storagePath()` what output do you get? – sam Feb 07 '18 at 15:26
  • @sam thanks for those thoughts. I had not cleared the cache and clearing the cache did not solve the issue. I checked the `app->storagePath()`, it shows the correct folder. So weird – Iannazzi Feb 10 '18 at 03:29
  • I come from your other question regarding the 404 for the schedule route. Do you manually restart or reload your nginx service after running the script? Seems like this guy had the same problem and solved it: https://stackoverflow.com/questions/19808884/nginx-and-or-php5-fpm-remembers-symlinked-root-directory – Eduardo Pacios Feb 15 '18 at 18:58
  • Yeah, that is the issue... – Iannazzi Feb 15 '18 at 19:11
  • @EduardoPacios I this other issue I had was the same problem: https://stackoverflow.com/questions/48727431/php-artisan-optimize-is-failing-on-production-server/48814976#48814976 – Iannazzi Feb 15 '18 at 19:36
  • Basically left unsure about the symlink style deployment... not sure I want to dig into nginx so the solution is currently to reboot – Iannazzi Feb 15 '18 at 19:37
  • Yeah, but does it work if you run ''sudo service nginx reload"? It's a common thing to do after adding, removing or modifying a symlink – Eduardo Pacios Feb 15 '18 at 23:19
  • Thanks, let me add that , that may be the correct answer – Iannazzi Feb 17 '18 at 01:05

0 Answers0