Git Product home page Git Product logo

Comments (4)

elithrar avatar elithrar commented on July 28, 2024 1

I'm not the author, and I'm not able to test this right now, but from looking at the source, goji accepts a -bind flag when using the default Serve function: ./myapp -bind :9090 will start your application on 0.0.0.0:9090.

If you want to make this the default (say, for interfacing with existing services or proxies), then you should be able to pass a net.Listener to graceful.Serve:

func BespokeServe() {
    http.Handle("/", goji.DefaultMux)
    listener, err := net.Listen("tcp", "127.0.0.1:9090")
    if err != nil {
        ...
    }

    err := graceful.Serve(listener, http.DefaultServeMux)
    if err != nil {
        ...
    }

    graceful.Wait()
}

from goji.

ekanna avatar ekanna commented on July 28, 2024 1

flag.Set("bind", ":1234")
Just put this before calling goji.Serve()
Don't forget to put colon : in front of port number.

It is working great!
Thanks

from goji.

sweetcheeks24 avatar sweetcheeks24 commented on July 28, 2024

That did it, thank you!

from goji.

zenazn avatar zenazn commented on July 28, 2024

You should also be able to set the flag explicitly (http://golang.org/pkg/flag/#Set). I haven't tested this, but if you do this above the call to goji.Serve() I bet this will have the same effect as changing the default.

from goji.

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.