forked from etcinit/phabulous
/
serve.go
38 lines (28 loc) · 835 Bytes
/
serve.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package app
import (
"strconv"
"github.com/Sirupsen/logrus"
"github.com/codegangsta/cli"
"github.com/etcinit/phabulous/app/bot"
"github.com/jacobstr/confer"
)
// ServeService provides the serve command
type ServeService struct {
Engine *EngineService `inject:""`
Config *confer.Config `inject:""`
Logger *logrus.Logger `inject:""`
Slacker *bot.SlackService `inject:""`
App *Phabulous `inject:""`
}
// Run starts up the HTTP server
func (s *ServeService) Run(c *cli.Context) {
// Boot the upper layers of the app.
s.App.Boot(c)
s.Logger.Infoln("Starting up the server... (a.k.a. coffee time)")
engine := s.Engine.New()
go s.Slacker.BootRTM()
// Figure out which port to use
port := ":" + strconv.Itoa(s.Config.GetInt("server.port"))
engine.Run(port)
s.Logger.Infoln("✔︎ Done!")
}