Packages

t

com.twitter.inject.server

TwitterServer

trait TwitterServer extends App with server.TwitterServer with Ports with Warmup

A com.twitter.server.TwitterServer that supports injection and com.twitter.inject.TwitterModule modules.

To use, override the appropriate @Lifecycle and callback method(s). Make sure when overriding

@Lifecycle

methods to call the super implementation, otherwise critical lifecycle set-up may not occur causing your server to either function improperly or outright fail.

If you are extending this trait, to implement your server, override the start() function, e.g.,

import com.twitter.inject.server.TwitterServer

object MyServerMain extends MyServer

class MyServer extends TwitterServer {
  override protected def start(): Unit = {
     // YOUR CODE HERE

     await(someAwaitable)
  }
}

Note, you do not need to await on the adminHttpServer as this is done for you by the framework.

Server Lifecycle: +-------------------------------------------------------------------------+

Life Cycle Method

Ancillary Function(s)

+-------------------------------------------------------------------------+

loadModules()

+-------------------------------------------------------------------------+

modules.postInjectorStartup()

foreach.singletonStartup()

+-------------------------------------------------------------------------+

postInjectorStartup()

resolveFinagleClientsOnStartup(),

setup()

+-------------------------------------------------------------------------+

warmup()

+-------------------------------------------------------------------------+

beforePostWarmup()

LifeCycle.Warmup.prebindWarmup()

+-------------------------------------------------------------------------+

postWarmup() (binds ext ports)

disable or announce admin server

+-------------------------------------------------------------------------+

afterpostwarmup()

LifeCycle.Warmup.warmupComplete()

+-------------------------------------------------------------------------+

setAppStarted()

+-------------------------------------------------------------------------+

run()

start()

+-------------------------------------------------------------------------+

Await on awaitables

+-------------------------------------------------------------------------+ @Lifecycle }}} occur causing your server to either function improperly or outright fail.

If you are extending this trait, to implement your server, override the start() function, e.g.,

import com.twitter.inject.server.TwitterServer

object MyServerMain extends MyServer

class MyServer extends TwitterServer {
  override protected def start(): Unit = {
     // YOUR CODE HERE

     await(someAwaitable)
  }
}

Note, you do not need to await on the adminHttpServer as this is done for you by the framework.

Server Lifecycle: +-------------------------------------------------------------------------+

Life Cycle Method

Ancillary Function(s)

+-------------------------------------------------------------------------+

loadModules()

+-------------------------------------------------------------------------+

modules.postInjectorStartup()

foreach.singletonStartup()

+-------------------------------------------------------------------------+

postInjectorStartup()

resolveFinagleClientsOnStartup(),

setup()

+-------------------------------------------------------------------------+

warmup()

+-------------------------------------------------------------------------+

beforePostWarmup()

LifeCycle.Warmup.prebindWarmup()

+-------------------------------------------------------------------------+

postWarmup() (binds ext ports)

disable or announce admin server

+-------------------------------------------------------------------------+

afterpostwarmup()

LifeCycle.Warmup.warmupComplete()

+-------------------------------------------------------------------------+

setAppStarted()

+-------------------------------------------------------------------------+

run()

start()

+-------------------------------------------------------------------------+

Await on awaitables

+-------------------------------------------------------------------------+

See also

Creating an Injectable TwitterServer

Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TwitterServer
  2. Warmup
  3. Ports
  4. TwitterServer
  5. Lifecycle
  6. AdminHttpServer
  7. Hooks
  8. DtabFlags
  9. Linters
  10. Stats
  11. App
  12. Logging
  13. Slf4jBridge
  14. App
  15. Lifecycle
  16. CloseOnceAwaitably
  17. CloseOnceAwaitably0
  18. Awaitable
  19. ClosableOnce
  20. CloseOnce
  21. Closable
  22. AnyRef
  23. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final val MinGrace: Duration
    Definition Classes
    App
  2. def addAdminRoute(route: Route): Unit
    Definition Classes
    AdminHttpServer
  3. def addAdminRoutes(newRoutes: Seq[Route]): Unit
    Definition Classes
    AdminHttpServer
  4. def addDtabs(): Unit
    Definition Classes
    DtabFlags
  5. def adminBoundAddress: InetSocketAddress
    Definition Classes
    AdminHttpServer
  6. val adminPort: Flag[InetSocketAddress]
    Definition Classes
    AdminHttpServer
  7. def args: Array[String]
    Definition Classes
    App
  8. final def close(deadline: Time): Future[Unit]
    Definition Classes
    CloseOnce → Closable
  9. def close(after: Duration): Future[Unit]
    Definition Classes
    Closable
  10. final def close(): Future[Unit]
    Definition Classes
    Closable
  11. final def closeOnExit(closable: Closable): Unit
    Definition Classes
    App
  12. final def closeOnExitLast(closable: Closable): Unit
    Definition Classes
    App
  13. def defaultAdminPort: Int
    Definition Classes
    AdminHttpServer
  14. def defaultCloseGracePeriod: Duration
    Definition Classes
    App
  15. val dtabAddBaseFlag: Flag[Dtab]
    Definition Classes
    DtabFlags
  16. final def flag: app.Flags
    Definition Classes
    App
  17. val group: String
    Definition Classes
    Lifecycle
  18. def httpExternalPort: Option[Int]

    Returns the bound port representing the external HTTP interface of this server.

    Returns the bound port representing the external HTTP interface of this server.

    returns

    a defined Some(Int) representing the port of the external HTTP interface if defined and bound, None otherwise.

    Definition Classes
    Ports
  19. def httpsExternalPort: Option[Int]

    Returns the bound port representing the external HTTPS interface of this server.

    Returns the bound port representing the external HTTPS interface of this server.

    returns

    a defined Some(Int) representing the port of the external HTTPS interface if defined and bound, None otherwise.

    Definition Classes
    Ports
  20. def injector: Injector
    Definition Classes
    App
  21. final def isClosed: Boolean
    Definition Classes
    CloseOnce
  22. def isReady(implicit permit: CanAwait): Boolean
    Definition Classes
    CloseOnceAwaitably0 → Awaitable
  23. def linterRules: Seq[Rule]
    Definition Classes
    Linters
  24. final def main(): Unit

    DO NOT BLOCK

    DO NOT BLOCK

    Definition Classes
    TwitterServerApp
  25. final def main(args: Array[String]): Unit
    Definition Classes
    App
  26. def name: String
    Definition Classes
    App
  27. final def nonExitingMain(args: Array[String]): Unit
    Definition Classes
    App
  28. def prebindWarmup(): Unit
    Definition Classes
    Warmup
  29. def ready(timeout: Duration)(implicit permit: CanAwait): TwitterServer.this.type
    Definition Classes
    CloseOnceAwaitably0 → Awaitable
  30. def result(timeout: Duration)(implicit permit: CanAwait): Unit
    Definition Classes
    CloseOnceAwaitably0 → Awaitable
  31. def routes: Seq[Route]
    Definition Classes
    AdminHttpServer
  32. def statsReceiver: StatsReceiver
    Definition Classes
    Stats
  33. final val suppressGracefulShutdownErrors: Boolean
    Definition Classes
    TwitterServer → App
  34. def thriftPort: Option[Int]

    Returns the bound port representing the external Thrift interface of this server.

    Returns the bound port representing the external Thrift interface of this server.

    returns

    a defined Some(Int) representing the port of the external Thrift interface if defined and bound, None otherwise.

    Definition Classes
    Ports
  35. def warmupComplete(): Unit
    Definition Classes
    Warmup