Skip to content

Commit facd386

Browse files
committed
优化自动安装的MySQL服务
1 parent f72902c commit facd386

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/web/actions/default/setup/mysql/mysqlinstallers/mysql_installer.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"net"
1616
"net/http"
1717
"os"
18+
"os/exec"
1819
"path/filepath"
1920
"regexp"
2021
"runtime"
@@ -569,6 +570,12 @@ func (this *MySQLInstaller) installService(baseDir string) error {
569570

570571
this.log("registering systemd service ...")
571572

573+
var startCmd = "${BASE_DIR}/support-files/mysql.server start"
574+
bashPath, _ := exec.LookPath("bash")
575+
if len(bashPath) > 0 {
576+
startCmd = bashPath + " -c \"" + startCmd + "\""
577+
}
578+
572579
var desc = `### BEGIN INIT INFO
573580
# Provides: mysql
574581
# Required-Start: $local_fs $network $remote_fs
@@ -589,7 +596,8 @@ After=network-online.target
589596
Type=simple
590597
Restart=on-failure
591598
RestartSec=5s
592-
ExecStart=${BASE_DIR}/support-files/mysql.server start
599+
RemainAfterExit=yes
600+
ExecStart=` + startCmd + `
593601
ExecStop=${BASE_DIR}/support-files/mysql.server stop
594602
ExecRestart=${BASE_DIR}/support-files/mysql.server restart
595603
ExecStatus=${BASE_DIR}/support-files/mysql.server status

0 commit comments

Comments
 (0)