-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Hi Tobias,
This is more of general feedback than an issue itself. I understand that the method of executing commands with shell_exec
works in the onAfterRoute
.
My feedback in more in line with the recommendation to avoid using onAfterRoute
for stuff that it is outside than what the web server should be doing (serving web pages). Since the web server has a configuration / security profile to serve pages, it can easily break the execution of a deployment.
Back to the extension, I would suggest a Cronjob execution with a CLI in the /file folder to execute the deployment.
Something like what Laravel does with the artisan
commands. This is a script that I use as a deployment cron job:
#!/bin/sh -e
NOW=`date +"%Y-%m-%d %H:%M"`
echo "***** $NOW - Deploying application ..."
cd ...
# Enter maintenance mode
(/usr/bin/php artisan down --message 'The service is being updated. Please try again in a few minutes.') || true
# Update codebase
git fetch origin deploy
git reset --hard origin/deploy
....
# Optimizing Configuration Loading
/usr/bin/php artisan config:cache
# Optimizing Route Loading
/usr/bin/php artisan route:cache
# Optimizing View Loading
/usr/bin/php artisan view:cache
# Migrate database
/usr/bin/php artisan migrate --force
....
# Clear cache
/usr/bin/php artisan optimize
# Reload PHP to update opcache
# echo "" | sudo -S service php7.4-fpm reload
# Exit maintenance mode
...
/usr/bin/php artisan up
NOW=`date +"%Y-%m-%d %H:%M"`
echo "***** $NOW - Application deployed!"
Hope this helps! Let us know if there is anything else we can do.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request