New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable admin #208

Closed
narcisobenigno opened this Issue May 20, 2015 · 10 comments

Comments

6 participants
@narcisobenigno

narcisobenigno commented May 20, 2015

Looks like I can not use admin on heroku... How can I disable it?

@cacoco

This comment has been minimized.

Member

cacoco commented May 20, 2015

@narcisobenigno can you explain a bit more what you mean when you say you can't use the admin? Can you also include any errors you're getting?

Thanks.

@schmitch

This comment has been minimized.

Contributor

schmitch commented May 26, 2015

Hi, I would like to disable the admin, too in some situations. However I don't have any problems with it yet, it's just dump when you need to configure multiple instances of finatra on a single server, ports clashing everywhere, so the less ports you need to configure, the better.

However I think it would still be great to have an admin module as a Guice Module, so we could just plug it in or plug it off easily.

Also it seems that httpAdminPort of the Ports trait has no function since the admin is configured in this way:

  def defaultHttpPort: Int = 9990
  val adminPort = flag("admin.port", new InetSocketAddress(defaultHttpPort), "Admin http server port")

I mean i could just overwrite defaultHttpPort, but still awefull. Looks like the whole trait has no effect..

EDIT:

  private def startHttpServer() {
    for (port <- parsePort(httpPortFlag)) {
      val serverBuilder = ServerBuilder()
        .codec(new RichHttp[Request](httpCodec))
        .bindTo(port)
        .name("http")

      configureHttpServer(serverBuilder)

      httpServer = serverBuilder.build(httpService)
      info("http server started on port: " + httpExternalPort.get)
    }
  }

Really strange code. the port comes from the httpPortFlag, which has a default of :8888 and then there is httpExternalPort inside the Ports trait which also defaults to :8888, but is only used for the info?!

wouldn't it be better to have something like if flag is not empty override httpExternalPort, so we could either overwrite httpExternalPort OR use the httpPortFlag?

@edma2

This comment has been minimized.

Contributor

edma2 commented May 26, 2015

The Ports trait is not meant for configuration. Its purpose is to expose the ports during integration tests so that HTTP clients can point at the correct destination.

https://github.com/twitter/finatra/blob/master/http/src/test/scala/com/twitter/finatra/http/test/EmbeddedHttpServer.scala#L39

@schmitch

This comment has been minimized.

Contributor

schmitch commented May 26, 2015

Oh however httpExternalPort is still used for the http server info message which is wrong.

OT: The next thing is there a way to set a flag inside the code?

@narcisobenigno

This comment has been minimized.

narcisobenigno commented May 26, 2015

Sorry by delay, and thanks by the feedback!

I don't know if is possible to configure in heroku to see de finatra admin dashboard. Then I wish to disable the dashboard (not startup it), just the server http port.

@cacoco

This comment has been minimized.

Member

cacoco commented May 28, 2015

@narcisobenigno it should be possible to just set the admin port twitter-server flag to 0, e.g.,

-admin.port=:0

I've tested this with a sample finatra application running on Heroku. Please let me know if that works for you. Thanks!

@narcisobenigno

This comment has been minimized.

narcisobenigno commented May 28, 2015

Okay, I will try.

Thanks

On Thu, May 28, 2015, 14:15 Christopher Coco notifications@github.com
wrote:

@narcisobenigno https://github.com/narcisobenigno it should be possible
to just set the admin port twitter-server flag to 0, e.g.,

-admin.port=:0

I've tested this with a sample finatra application running on Heroku.
Please let me know if that works for you. Thanks!


Reply to this email directly or view it on GitHub
#208 (comment).

@cacoco cacoco closed this Jun 13, 2015

@sergio91pt

This comment has been minimized.

sergio91pt commented Jun 25, 2015

@cacoco @narcisobenigno Setting the port to 0, assigns a random port bound to all interfaces. You can check with sudo netstat -plunt

@cacoco

This comment has been minimized.

Member

cacoco commented Jun 25, 2015

@sergio91pt yep -- unfortunately there's no way to get two assigned ports with Heroku currently so this is the workaround. You won't be able to access the admin as like you said it will be on some random port. Thanks!

@theyelllowdart

This comment has been minimized.

theyelllowdart commented Mar 6, 2016

It's hacky but this works on Heroku.

Procfile
web: target/universal/stage/bin/hello-world -- -admin.port=:0 -http.port=:$PORT

Server/Module

class AdminClientModule(adminServer: => ListeningServer) extends HttpClientModule {
  override def dest: String = ":" + adminServer.boundAddress.asInstanceOf[InetSocketAddress].getPort
}

object HelloWorldMain extends HelloWorldServer

class HelloWorldServer extends HttpServer {

  override protected def modules: Seq[Module] = Vector(new AdminClientModule(adminHttpServer))
  ...
}

Controller

class AdminController @Inject()(httpClient: HttpClient) extends Controller {

  // NOTE(aaron): Use a wildcard in order to avoid being catalogued as an admin route in HttpRouter.partitionRoutesByType.
  get("/admi:*") { request: Request =>
    httpClient.execute(request)
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment