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
|
|
41
drone.go
41
drone.go
|
@ -1,7 +1,7 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"net/http"
|
||||||
|
|
||||||
"github.com/drone/drone/engine"
|
"github.com/drone/drone/engine"
|
||||||
"github.com/drone/drone/remote"
|
"github.com/drone/drone/remote"
|
||||||
|
@ -10,19 +10,23 @@ import (
|
||||||
"github.com/drone/drone/router/middleware/context"
|
"github.com/drone/drone/router/middleware/context"
|
||||||
"github.com/drone/drone/router/middleware/header"
|
"github.com/drone/drone/router/middleware/header"
|
||||||
"github.com/drone/drone/shared/envconfig"
|
"github.com/drone/drone/shared/envconfig"
|
||||||
"github.com/drone/drone/shared/server"
|
|
||||||
"github.com/drone/drone/store/datastore"
|
"github.com/drone/drone/store/datastore"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/ianschenck/envflag"
|
||||||
|
_ "github.com/joho/godotenv/autoload"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
dotenv = flag.String("config", ".env", "")
|
addr = envflag.String("SERVER_ADDR", ":8000", "")
|
||||||
debug = flag.Bool("debug", false, "")
|
cert = envflag.String("SERVER_CERT", "", "")
|
||||||
|
key = envflag.String("SERVER_KEY", "", "")
|
||||||
|
|
||||||
|
debug = envflag.Bool("DEBUG", false, "")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
envflag.Parse()
|
||||||
|
|
||||||
// debug level if requested by user
|
// debug level if requested by user
|
||||||
if *debug {
|
if *debug {
|
||||||
|
@ -30,7 +34,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the configuration from env file
|
// Load the configuration from env file
|
||||||
env := envconfig.Load(*dotenv)
|
env := envconfig.Load(".env")
|
||||||
|
|
||||||
// Setup the database driver
|
// Setup the database driver
|
||||||
store_ := datastore.Load(env)
|
store_ := datastore.Load(env)
|
||||||
|
@ -42,14 +46,21 @@ func main() {
|
||||||
engine_ := engine.Load(env, store_)
|
engine_ := engine.Load(env, store_)
|
||||||
|
|
||||||
// setup the server and start the listener
|
// setup the server and start the listener
|
||||||
server_ := server.Load(env)
|
handler := router.Load(
|
||||||
server_.Run(
|
header.Version,
|
||||||
router.Load(
|
cache.Default(),
|
||||||
header.Version,
|
context.SetStore(store_),
|
||||||
cache.Default(),
|
context.SetRemote(remote_),
|
||||||
context.SetStore(store_),
|
context.SetEngine(engine_),
|
||||||
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