MCPcopy Create free account
hub / github.com/kataras/iris / Run

Method Run

iris.go:1050–1083  ·  view source on GitHub ↗

Run builds the framework and starts the desired `Runner` with or without configuration edits. Run should be called only once per Application instance, it blocks like http.Server. If more than one server needed to run on the same iris instance then create a new host and run it manually by `go NewHo

(serve Runner, withOrWithout ...Configurator)

Source from the content-addressed store, hash-verified

1048// the following runners:
1049// `Listener`, `Server`, `Addr`, `TLS`, `AutoTLS` and `Raw`.
1050func (app *Application) Run(serve Runner, withOrWithout ...Configurator) error {
1051 app.Configure(withOrWithout...)
1052
1053 if err := app.Build(); err != nil {
1054 app.logger.Error(err)
1055 return err
1056 }
1057
1058 app.ConfigureHost(func(host *Supervisor) {
1059 host.SocketSharding = app.config.SocketSharding
1060 host.KeepAlive = app.config.KeepAlive
1061 })
1062
1063 app.tryStartTunneling()
1064
1065 if len(app.Hosts) > 0 {
1066 app.logger.Debugf("Application: running using %d host(s)", len(app.Hosts)+1 /* +1 the current */)
1067 }
1068
1069 if app.config.NonBlocking {
1070 go func() {
1071 err := app.serve(serve)
1072 if err != nil {
1073 app.setRunError(err)
1074 }
1075 }()
1076
1077 return nil
1078 }
1079
1080 // this will block until an error(unless supervisor's DeferFlow called from a Task)
1081 // or NonBlocking was passed (see above).
1082 return app.serve(serve)
1083}
1084
1085func (app *Application) serve(serve Runner) error {
1086 err := serve(app)

Callers 1

ListenMethod · 0.95

Calls 7

ConfigureMethod · 0.95
BuildMethod · 0.95
ConfigureHostMethod · 0.95
tryStartTunnelingMethod · 0.95
serveMethod · 0.95
setRunErrorMethod · 0.95
ErrorMethod · 0.65

Tested by

no test coverage detected