From ca75f9b22cd0e2254a5f7d832b13ad49180e55e5 Mon Sep 17 00:00:00 2001 From: Michael Eisendle Date: Mon, 23 Feb 2015 15:27:48 +0100 Subject: [PATCH] + add support to run custom server logic (e.g. listen on multiple addresses) --- harness/build.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/harness/build.go b/harness/build.go index 29383a34..660c4811 100755 --- a/harness/build.go +++ b/harness/build.go @@ -42,12 +42,22 @@ func Build(buildFlags ...string) (app *App, compileError *revel.Error) { sourceInfo.InitImportPaths = append(sourceInfo.InitImportPaths, dbImportPath) } + importPaths := calcImportAliases(sourceInfo) + + // Add the custom server import path + var customServer bool + if serverImportPath, found := revel.Config.String("module.server"); found { + importPaths[serverImportPath] = "server" + customServer = true + } + // Generate two source files. templateArgs := map[string]interface{}{ "Controllers": sourceInfo.ControllerSpecs(), "ValidationKeys": sourceInfo.ValidationKeys, - "ImportPaths": calcImportAliases(sourceInfo), + "ImportPaths": importPaths, "TestSuites": sourceInfo.TestSuites(), + "CustomServer": customServer, } genSource("tmp", "main.go", RevelMainTemplate, templateArgs) genSource("routes", "routes.go", RevelRoutesTemplate, templateArgs) @@ -418,7 +428,11 @@ func main() { (*{{index $.ImportPaths .ImportPath}}.{{.StructName}})(nil),{{end}} } + {{if .CustomServer}} + server.Run(revel.InitServer()) + {{else}} revel.Run(*port) + {{end}} } `