Skip to content

Commit

Permalink
chore: go-gin service configuration (#12)
Browse files Browse the repository at this point in the history
* Update go-gin.plist configuration file

* Update RestartSec in go-gin.service

* Update go-gin service configuration

* Update GG_REPO_BRANCH in install.sh

* Add instructions for running as a service on Linux
  • Loading branch information
funnyzak authored Feb 19, 2024
1 parent 81e9ea0 commit 0bde45a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion script/go-gin.plist
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<array>
<string>/opt/go-gin/go-gin</string>
<string>-c</string>
<string>/opt/go-gin/config.yaml</string>
<string>go-gin</string>
</array>
<key>KeepAlive</key>
<true/>
Expand Down
5 changes: 1 addition & 4 deletions script/go-gin.service
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions script/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0bde45a

Please sign in to comment.