Giter Club home page Giter Club logo

Comments (13)

buger avatar buger commented on May 18, 2024

http://mmcgrana.github.io/2012/09/getting-started-with-go-on-heroku.html

I not tested it, but basic idea is that you can upload binary to your repo, or create new folder. And then add Gor to Procfile, smth like: "gor: gor listen -p 8080"

from goreplay.

dfuentes77 avatar dfuentes77 commented on May 18, 2024

I'm guessing it would have to be integrated into a heroku buildpack since it needs to run along side whatever our web machines are running. And that's assuming Heroku's dynos allow gor to listen on a port that's already bound by the application being hosted.

from goreplay.

fern4lvarez avatar fern4lvarez commented on May 18, 2024

I believe this is not current possible, since the slug doesn't contain the 'gor' binary.

There would be a way to achieve this programatically letting a regular worker running on the background, as follows:

package main

import (
    "fmt"
    "os"

    "github.com/buger/gor/listener"
)

func main() {
    // Set up listener
    s := listener.ListenerSettings{}
    s.Port = os.Getenv("PORT") // $PORT, where container is running
    s.Address = "0.0.0.0"       // Default address?
    s.ReplayAddress = "0.0.0.0" // Replay server address `Address:Port`
    s.ReplayLimit = 10          // Limit if required

    // Run listener based on `s` settings
    fmt.Println("Listening on", s.Address, s.Port)
    listener.Run(s)
}

But this would need few changes on the Gor API. For instance, the listener.Run() method relies on the Settings global variable created out of the CLI parameters. A Run() method, or call it whatever you like, having a listener.ListenerSettings as a parameter would do then thing, so you could set on your program your own requirements and then fire the listener up.

Still, I'm not sure what would be the listener address inside the slug.

from goreplay.

buger avatar buger commented on May 18, 2024

Or i can add HTTP input to Gor, so requests can be send to Gor without raw sockets.

from goreplay.

fern4lvarez avatar fern4lvarez commented on May 18, 2024

Anyway, I was wrong, it is possible handle directly from outside the listener.Settings global var:

package main

import (
    "fmt"
    "os"

    "github.com/buger/gor/listener"
)

func main() {
    // Set up listener
    s := listener.Settings
    s.Port = os.Getenv("PORT") // $PORT, where container is running
    s.Address = "0.0.0.0"       // Default address?
    s.ReplayAddress = "0.0.0.0" // Replay server address `Address:Port`
    s.ReplayLimit = 10          // Limit if required

    // Run listener based on `s` settings
    fmt.Println("Listening on", s.Address, s.Port)
    listener.Run()
}

Didn't tested it though.

from goreplay.

slawosz avatar slawosz commented on May 18, 2024

I see a lot of potential in gor by making it more modulary. Something like this:

listener = gor.Listener{Port: os.Getenv("PORT"), ListenAddress: "0.0.0.0", ReplayAddress: "0.0.0.0"} // or gor.NewListener....
fmt.Println(listener.Settings)
listener.Listen()

from goreplay.

buger avatar buger commented on May 18, 2024

@slawosz i'm open to new ideas, feel free to create new issue, with nice description what you want to see and why it may be needed, so we can continue this conversation.

from goreplay.

buger avatar buger commented on May 18, 2024

I added http input https://github.com/buger/gor#guarante-of-replay-and-http-input

It can help in cases like Heroku.

from goreplay.

doublerebel avatar doublerebel commented on May 18, 2024

I'm looking at implementing exactly this use case. Has anyone here put this concept into practice on Heroku?

from goreplay.

buger avatar buger commented on May 18, 2024

@doublerebel you mean HTTP input or embedding Gor as library?

from goreplay.

doublerebel avatar doublerebel commented on May 18, 2024

@buger Both, actually. Embedding Gor as library and listening for HTTP input on the port of the Heroku-hosted application.

from goreplay.

buger avatar buger commented on May 18, 2024

I see, it should be possible same way i write tests:
https://github.com/buger/gor/blob/master/input_raw_test.go

input := gor.NewRAWInput("localhost:80")
output := gor.NewTCPOutput("replay:27017")
gor.Plugins.Inputs = []io.Reader{input}
gor.Plugins.Outputs = []io.Writer{output}
gor.Start()

Currently problem that all code is located in main package. So to make it work like above we need to move all Gor code to new package, and leave only 1 file in main package which will generate binary.

Not sure if i can/willing to do it in near future, but if someone wants i will help.

from goreplay.

jtrim avatar jtrim commented on May 18, 2024

I made it as far as getting a Gor buildpack onto Heroku. The problem I'm running into is that sudo is required for --input-raw, and as far as I can tell, Heroku doesn't expose root access to the application context.

from goreplay.

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.