Pay attention to the problem

  1. After the GO project is run, the modification of the. Env file does not take effect immediately. The modification takes effect only after the Go service is restarted
  2. After the go project is run, the modification of the config.ini configuration file takes effect immediately without restarting the Go service

Redeploy the project

  • Development environment rebuild project (Package syntax for Mac environment)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
Copy the code
  • Find the process blogger’s port number 9001 for the specified port
netstat -tunlp|grep 9001
Copy the code

Note: Thanks for digg’s comments, the production environment ‘kill-9’ is too violent and can cause problems: processes terminate abruptly while running and can’t clean themselves up after they finish.

  • Therefore, the production environment recommends that you use:
    • 4543 is the process PID to terminate
    • Singo is the binary file name
    • Run the && command simultaneously to avoid service interruption
kill 4543 && nohup ./singo > nohup.log 2>&1 &
Copy the code
  • To force the process to end, run the kill -9 command:
    • 4543 is the process PID to terminate
    • Singo is the binary file name
    • Run the && command simultaneously to avoid service interruption
kill -9 4543 && nohup ./singo > nohup.log 2>&1 &
Copy the code

Appendix Packaging syntax for Windows platform

windows

Set CGO_ENABLED=0 // Disable CGO set GOOS= Linux // Target platform is Linux set GOARCH=amd64 // target processor architecture is AMd64 go build-o name // Compile executable file to current directory (-o: user-defined file name)Copy the code

Mac

CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
Copy the code
  • Reference document: Thanks to Q1mi teacher’s blog