优化自动安装的MySQL服务

This commit is contained in:
刘祥超
2024-03-08 20:02:47 +08:00
parent f72902cd8d
commit facd386cf7

View File

@@ -15,6 +15,7 @@ import (
"net" "net"
"net/http" "net/http"
"os" "os"
"os/exec"
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime" "runtime"
@@ -569,6 +570,12 @@ func (this *MySQLInstaller) installService(baseDir string) error {
this.log("registering systemd service ...") this.log("registering systemd service ...")
var startCmd = "${BASE_DIR}/support-files/mysql.server start"
bashPath, _ := exec.LookPath("bash")
if len(bashPath) > 0 {
startCmd = bashPath + " -c \"" + startCmd + "\""
}
var desc = `### BEGIN INIT INFO var desc = `### BEGIN INIT INFO
# Provides: mysql # Provides: mysql
# Required-Start: $local_fs $network $remote_fs # Required-Start: $local_fs $network $remote_fs
@@ -589,7 +596,8 @@ After=network-online.target
Type=simple Type=simple
Restart=on-failure Restart=on-failure
RestartSec=5s RestartSec=5s
ExecStart=${BASE_DIR}/support-files/mysql.server start RemainAfterExit=yes
ExecStart=` + startCmd + `
ExecStop=${BASE_DIR}/support-files/mysql.server stop ExecStop=${BASE_DIR}/support-files/mysql.server stop
ExecRestart=${BASE_DIR}/support-files/mysql.server restart ExecRestart=${BASE_DIR}/support-files/mysql.server restart
ExecStatus=${BASE_DIR}/support-files/mysql.server status ExecStatus=${BASE_DIR}/support-files/mysql.server status