Selaa lähdekoodia

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

BrettonYe 2 vuotta sitten
vanhempi
sitoutus
1e4db0be56
3 muutettua tiedostoa jossa 20 lisäystä ja 22 poistoa
  1. 6 1
      app/Console/Commands/PanelInstallation.php
  2. 12 15
      install.sh
  3. 2 6
      update.sh

+ 6 - 1
app/Console/Commands/PanelInstallation.php

@@ -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();
 

+ 12 - 15
install.sh

@@ -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

+ 2 - 6
update.sh

@@ -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