diff --git a/README.md b/README.md index c3f48c2..cedfe4d 100644 --- a/README.md +++ b/README.md @@ -211,6 +211,16 @@ You can pull the source code to compile the binary executable file yourself, or **Note:** Please make sure that executable permissions have been set before running. If there are no executable permissions, you can set them through the `chmod +x go-gin` command. +## Run as Service + +### Linux (systemd) + +In Linux, services are managed through Systemd. You can use the following commands to install, start, stop, restart, log, and view the status of services, etc. + +```bash +bash -c "$(curl -fsSL https://raw.githubusercontent.com/funnyzak/go-gin/main/script/install.sh)" +``` + ## License MIT License diff --git a/script/go-gin.plist b/script/go-gin.plist index 012dceb..e8d87ec 100644 --- a/script/go-gin.plist +++ b/script/go-gin.plist @@ -9,7 +9,7 @@ /opt/go-gin/go-gin -c - /opt/go-gin/config.yaml + go-gin KeepAlive diff --git a/script/go-gin.service b/script/go-gin.service index 88199b6..fe58d4f 100644 --- a/script/go-gin.service +++ b/script/go-gin.service @@ -3,11 +3,8 @@ Description=go-gin service After=syslog.target [Service] -Type=simple -User=nobody -Group=nogroup Restart=on-failure -RestartSec=30s +RestartSec=10s WorkingDirectory=/opt/go-gin ExecStart=/opt/go-gin/go-gin -c go-gin diff --git a/script/install.sh b/script/install.sh index 1496ec9..3ccee47 100644 --- a/script/install.sh +++ b/script/install.sh @@ -18,7 +18,7 @@ GG_DESCRIPTION="Go-Gin is a web service based on Golang and Gin framework." # se GG_NAME="go-gin" # service name GG_REPO_NAME="funnyzak/${GG_NAME}" # service repo name -GG_REPO_BRANCH="installsrcipt" # service repo branch +GG_REPO_BRANCH="main" # service repo branch GG_SERVICE_NAME="${GG_NAME}" # service system name GG_WORK_PATH="/opt/${GG_SERVICE_NAME}" # service workdir path @@ -279,7 +279,7 @@ show_service_log() { fi echo -e "Press ${red}Ctrl+C${plain} to exit." - watch -n 1 tail -n 20 “$(get_service_log_path)” + watch -n 1 tail -n 20 "$(get_service_log_path)" if [[ $# == 0 ]]; then before_show_menu