优化安装过程错误时的清理

This commit is contained in:
BrettonYe
2023-06-20 00:26:51 +08:00
committed by BrettonYe
parent 0fadbad78f
commit 1e4db0be56
3 changed files with 20 additions and 22 deletions

View File

@@ -67,7 +67,12 @@ class PanelInstallation extends Command
// 初始化数据库
$this->line(' 导入数据库');
Artisan::call('migrate --seed');
try {
Artisan::call('migrate --seed');
} catch (Exception $e) {
Artisan::call('db:wipe');
abort(500, '导入数据库失败'.$e->getMessage());
}
$this->info('数据库导入完成');
$bar->advance();

View File

@@ -55,13 +55,9 @@ check_sys() {
#检查composer是否安装
check_composer() {
if [ ! -f "/usr/bin/composer" ]; then
if [[ "${release}" == "centos" ]]; then
yum install -y composer
else
apt-get install -y composer
fi
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
else
if [[ $(composer --version | cut -d" " -f3) < 2.2.0 ]]; then
if [[ $(composer -n --version --no-ansi | cut -d" " -f3) < 2.2.0 ]]; then
composer self-update
fi
fi
@@ -98,15 +94,16 @@ set_horizon() {
if [ ! -f /etc/supervisor/conf.d/horizon.conf ]; then
echo "
[program:horizon]
process_name=%(program_name)s
command=php $PWD/artisan horizon
autostart=true
autorestart=true
user=www
redirect_stderr=true
stdout_logfile=$PWD/storage/logs/horizon.log
stopwaitsecs=3600" >>/etc/supervisor/conf.d/horizon.conf
[program:horizon]
process_name=%(program_name)s
command=php $PWD/artisan horizon
autostart=true
autorestart=true
user=www
redirect_stderr=true
stdout_logfile=$PWD/storage/logs/horizon.log
stopwaitsecs=3600" >>/etc/supervisor/conf.d/horizon.conf
supervisorctl reread
supervisorctl update
supervisorctl start horizon

View File

@@ -21,13 +21,9 @@ check_sys() {
#检查composer是否安装
check_composer() {
if [ ! -f "/usr/bin/composer" ]; then
if [[ "${release}" == "centos" ]]; then
yum install -y composer
else
apt-get install -y composer
fi
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
else
if [[ $(composer --version | cut -d" " -f3) < 2.2.0 ]]; then
if [[ $(composer -n --version --no-ansi | cut -d" " -f3) < 2.2.0 ]]; then
composer self-update
fi
fi