MCPcopy Index your code
hub / github.com/codegangsta/gin / MainAction

Function MainAction

main.go:145–212  ·  view source on GitHub ↗
(c *cli.Context)

Source from the content-addressed store, hash-verified

143}
144
145func MainAction(c *cli.Context) {
146 laddr := c.GlobalString("laddr")
147 port := c.GlobalInt("port")
148 all := c.GlobalBool("all")
149 appPort := strconv.Itoa(c.GlobalInt("appPort"))
150 immediate = c.GlobalBool("immediate")
151 keyFile := c.GlobalString("keyFile")
152 certFile := c.GlobalString("certFile")
153 logPrefix := c.GlobalString("logPrefix")
154 notifications = c.GlobalBool("notifications")
155
156 logger.SetPrefix(fmt.Sprintf("[%s] ", logPrefix))
157
158 // Bootstrap the environment
159 envy.Bootstrap()
160
161 // Set the PORT env
162 os.Setenv("PORT", appPort)
163
164 wd, err := os.Getwd()
165 if err != nil {
166 logger.Fatal(err)
167 }
168
169 buildArgs, err := shellwords.Parse(c.GlobalString("buildArgs"))
170 if err != nil {
171 logger.Fatal(err)
172 }
173
174 buildPath := c.GlobalString("build")
175 if buildPath == "" {
176 buildPath = c.GlobalString("path")
177 }
178 builder := gin.NewBuilder(buildPath, c.GlobalString("bin"), c.GlobalBool("godep"), wd, buildArgs)
179 runner := gin.NewRunner(filepath.Join(wd, builder.Binary()), c.Args()...)
180 runner.SetWriter(os.Stdout)
181 proxy := gin.NewProxy(builder, runner)
182
183 config := &gin.Config{
184 Laddr: laddr,
185 Port: port,
186 ProxyTo: "http://localhost:" + appPort,
187 KeyFile: keyFile,
188 CertFile: certFile,
189 }
190
191 err = proxy.Run(config)
192 if err != nil {
193 logger.Fatal(err)
194 }
195
196 if laddr != "" {
197 logger.Printf("Listening at %s:%d\n", laddr, port)
198 } else {
199 logger.Printf("Listening on port %d\n", port)
200 }
201
202 shutdown(runner)

Callers

nothing calls this directly

Calls 7

BinaryMethod · 0.95
SetWriterMethod · 0.95
RunMethod · 0.95
KillMethod · 0.95
shutdownFunction · 0.85
buildFunction · 0.85
scanChangesFunction · 0.85

Tested by

no test coverage detected