removed server package
This commit is contained in:
parent
380b205f83
commit
cc93df0370
3 changed files with 26 additions and 61 deletions
|
@ -1,10 +0,0 @@
|
|||
# build environment used in .drone.yml
|
||||
#
|
||||
# docker build --rm=true -t drone/golang:1.5 -f Dockerfile.env .
|
||||
|
||||
FROM golang:1.5
|
||||
ADD contrib/*.sh /usr/local/bin/
|
||||
RUN chmod +x /usr/local/bin/setup-sassc.sh && \
|
||||
chmod +x /usr/local/bin/setup-sqlite.sh && \
|
||||
/usr/local/bin/setup-sassc.sh && \
|
||||
/usr/local/bin/setup-sqlite.sh
|
31
drone.go
31
drone.go
|
@ -1,7 +1,7 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"net/http"
|
||||
|
||||
"github.com/drone/drone/engine"
|
||||
"github.com/drone/drone/remote"
|
||||
|
@ -10,19 +10,23 @@ import (
|
|||
"github.com/drone/drone/router/middleware/context"
|
||||
"github.com/drone/drone/router/middleware/header"
|
||||
"github.com/drone/drone/shared/envconfig"
|
||||
"github.com/drone/drone/shared/server"
|
||||
"github.com/drone/drone/store/datastore"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/ianschenck/envflag"
|
||||
_ "github.com/joho/godotenv/autoload"
|
||||
)
|
||||
|
||||
var (
|
||||
dotenv = flag.String("config", ".env", "")
|
||||
debug = flag.Bool("debug", false, "")
|
||||
addr = envflag.String("SERVER_ADDR", ":8000", "")
|
||||
cert = envflag.String("SERVER_CERT", "", "")
|
||||
key = envflag.String("SERVER_KEY", "", "")
|
||||
|
||||
debug = envflag.Bool("DEBUG", false, "")
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
envflag.Parse()
|
||||
|
||||
// debug level if requested by user
|
||||
if *debug {
|
||||
|
@ -30,7 +34,7 @@ func main() {
|
|||
}
|
||||
|
||||
// Load the configuration from env file
|
||||
env := envconfig.Load(*dotenv)
|
||||
env := envconfig.Load(".env")
|
||||
|
||||
// Setup the database driver
|
||||
store_ := datastore.Load(env)
|
||||
|
@ -42,14 +46,21 @@ func main() {
|
|||
engine_ := engine.Load(env, store_)
|
||||
|
||||
// setup the server and start the listener
|
||||
server_ := server.Load(env)
|
||||
server_.Run(
|
||||
router.Load(
|
||||
handler := router.Load(
|
||||
header.Version,
|
||||
cache.Default(),
|
||||
context.SetStore(store_),
|
||||
context.SetRemote(remote_),
|
||||
context.SetEngine(engine_),
|
||||
),
|
||||
)
|
||||
|
||||
if *cert != "" {
|
||||
logrus.Fatal(
|
||||
http.ListenAndServeTLS(*addr, *cert, *key, handler),
|
||||
)
|
||||
} else {
|
||||
logrus.Fatal(
|
||||
http.ListenAndServe(*addr, handler),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/drone/drone/shared/envconfig"
|
||||
)
|
||||
|
||||
type Server struct {
|
||||
Addr string
|
||||
Cert string
|
||||
Key string
|
||||
}
|
||||
|
||||
func Load(env envconfig.Env) *Server {
|
||||
return &Server{
|
||||
Addr: env.String("SERVER_ADDR", ":8000"),
|
||||
Cert: env.String("SERVER_CERT", ""),
|
||||
Key: env.String("SERVER_KEY", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) Run(handler http.Handler) {
|
||||
log.Infof("starting server %s", s.Addr)
|
||||
|
||||
if len(s.Cert) != 0 {
|
||||
log.Fatal(
|
||||
http.ListenAndServeTLS(s.Addr, s.Cert, s.Key, handler),
|
||||
)
|
||||
} else {
|
||||
log.Fatal(
|
||||
http.ListenAndServe(s.Addr, handler),
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue