Merge pull request #1851 from bradrydzewski/feature/mq

ability to enable broker debugging
This commit is contained in:
Brad Rydzewski 2016-11-11 09:53:11 +00:00 committed by GitHub
commit 5bac61dc4b
2 changed files with 17 additions and 1 deletions

View file

@ -26,6 +26,11 @@ var serverCmd = cli.Command{
Name: "debug", Name: "debug",
Usage: "start the server in debug mode", Usage: "start the server in debug mode",
}, },
cli.BoolFlag{
EnvVar: "DRONE_BROKER_DEBUG",
Name: "broker-debug",
Usage: "start the broker in debug mode",
},
cli.StringFlag{ cli.StringFlag{
EnvVar: "DRONE_SERVER_ADDR", EnvVar: "DRONE_SERVER_ADDR",
Name: "server-addr", Name: "server-addr",

View file

@ -1,16 +1,19 @@
package middleware package middleware
import ( import (
"os"
"sync" "sync"
handlers "github.com/drone/drone/server" handlers "github.com/drone/drone/server"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"github.com/drone/mq/logger"
"github.com/drone/mq/server" "github.com/drone/mq/server"
"github.com/drone/mq/stomp" "github.com/drone/mq/stomp"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/tidwall/redlog"
) )
const ( const (
@ -23,7 +26,15 @@ const (
func Broker(cli *cli.Context) gin.HandlerFunc { func Broker(cli *cli.Context) gin.HandlerFunc {
secret := cli.String("agent-secret") secret := cli.String("agent-secret")
if secret == "" { if secret == "" {
logrus.Fatalf("failed to generate token from DRONE_SECRET") logrus.Fatalf("fatal error. please provide the DRONE_SECRET")
}
// setup broker logging.
log := redlog.New(os.Stderr)
log.SetLevel(0)
logger.SetLogger(log)
if cli.Bool("broker-debug") {
log.SetLevel(1)
} }
broker := server.NewServer( broker := server.NewServer(