Skip to content

Commit

Permalink
compose: Add flag to run Ratel. (hypermodeinc#3802)
Browse files Browse the repository at this point in the history
This adds --ratel and --ratel_port flags to run Ratel via the compose tool.

Run default compose cluster with Ratel running at port 8000

    ./compose --ratel

Run default compose cluster with Ratel running at port 8001

    ./compose --ratel --ratel_port=8001
  • Loading branch information
danielmai authored Aug 13, 2019
1 parent c594918 commit dc1d25e
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions compose/compose.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ type options struct {
LocalBin bool
Tag string
WhiteList bool
Ratel bool
RatelPort int
}

var opts options
Expand Down Expand Up @@ -248,6 +250,22 @@ func getJaeger() service {
return svc
}

func getRatel() service {
portFlag := ""
if opts.RatelPort != 8000 {
portFlag = fmt.Sprintf(" -port=%d", opts.RatelPort)
}
svc := service{
Image: "dgraph/dgraph:" + opts.Tag,
ContainerName: "ratel",
Ports: []string{
toExposedPort(opts.RatelPort),
},
Command: "dgraph-ratel" + portFlag,
}
return svc
}

func addMetrics(cfg *composeConfig) {
cfg.Volumes["prometheus-volume"] = stringMap{}
cfg.Volumes["grafana-volume"] = stringMap{}
Expand Down Expand Up @@ -363,6 +381,10 @@ func main() {
"Docker tag for dgraph/dgraph image. Requires -l=false to use binary from docker container.")
cmd.PersistentFlags().BoolVarP(&opts.WhiteList, "whitelist", "w", false,
"include a whitelist if true")
cmd.PersistentFlags().BoolVar(&opts.Ratel, "ratel", false,
"include ratel service")
cmd.PersistentFlags().IntVar(&opts.RatelPort, "ratel_port", 8000,
"Port to expose Ratel service")

err := cmd.ParseFlags(os.Args)
if err != nil {
Expand Down Expand Up @@ -396,6 +418,9 @@ func main() {
if opts.UserOwnership && opts.DataDir == "" {
fatal(errors.Errorf("--user option requires --data_dir=<path>"))
}
if cmd.Flags().Changed("ratel_port") && !opts.Ratel {
fatal(errors.Errorf("--ratel_port option requires --ratel"))
}

services := make(map[string]service)

Expand Down Expand Up @@ -423,6 +448,10 @@ func main() {
services["jaeger"] = getJaeger()
}

if opts.Ratel {
services["ratel"] = getRatel()
}

if opts.Metrics {
addMetrics(&cfg)
}
Expand Down

0 comments on commit dc1d25e

Please sign in to comment.