GithubHelp home page GithubHelp logo

Can atreugo be hot upgrade? about atreugo HOT 4 CLOSED

savsgio avatar savsgio commented on July 19, 2024
Can atreugo be hot upgrade?

from atreugo.

Comments (4)

savsgio avatar savsgio commented on July 19, 2024

Do you mean a Hot reload about configuration (like host, compression, etc)?
What do you need exactly?

from atreugo.

imxxiv avatar imxxiv commented on July 19, 2024

After the change of business logic, need to reload.
For example, an api interface method has been added, need gracefully reload.

from atreugo.

savsgio avatar savsgio commented on July 19, 2024

In compiled languages like Go, Java, C, etc, you must recompile your programe if you change the code (bussines logic).

GracefulShutdown just wait to finish incomplete requests, and shutdown server.

Sorry.

from atreugo.

imxxiv avatar imxxiv commented on July 19, 2024

https://gravitational.com/blog/golang-ssh-bastion-graceful-restarts/
In the example of this page

  1. $ go build restart.go
    $ ./restart &
    [1] 28323
    Created listener file descriptor for :8080.
    $ curl http://127.0.0.1:8080/hello
    Hello from 28323!
    $ curl http://127.0.0.1:8080/test
    404 page not found

  2. add testHandler

func testHandler(w http.ResponseWriter, r *http.Request) {
	fmt.Fprintf(w, "Test from %v!\n", os.Getpid())
}

func startServer(addr string, ln net.Listener) *http.Server {
	http.HandleFunc("/hello", handler)
	http.HandleFunc("/test", testHandler)

	httpServer := &http.Server{
		Addr: addr,
	}
	go httpServer.Serve(ln)

	return httpServer
}
  1. $ go build restart.go

  2. $ kill -SIGUSR2 28323
    user defined signal 2 signal received.
    Forked child 28432.
    Imported listener file descriptor for :8080.
    $ curl http://127.0.0.1:8080/test
    Test from 28432!
    $ curl http://127.0.0.1:8080/hello
    Hello from 28432!

  3. $ kill -SIGTERM 28323

Program can gracefully restart.
Can atreugo use this way?
Use kill command or cur http://127.0.0.1:8080/restart

from atreugo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.