-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
129 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
FROM golang:1.6.2-alpine | ||
|
||
MAINTAINER TFG Co <backend@tfgco.com> | ||
|
||
EXPOSE 8888 | ||
|
||
RUN apk update | ||
RUN apk add --update git make g++ apache2-utils bash | ||
|
||
RUN go get -u github.com/Masterminds/glide/... | ||
|
||
ADD . /go/src/github.com/topfreegames/donations | ||
|
||
WORKDIR /go/src/github.com/topfreegames/donations | ||
RUN glide install | ||
RUN go install github.com/topfreegames/donations | ||
|
||
ENV DONATIONS_MONGODB_HOST 0.0.0.0 | ||
ENV DONATIONS_MONGODB_PORT 27017 | ||
ENV DONATIONS_MONGODB_DB donations | ||
ENV DONATIONS_REDIS_URL redis://0.0.0.0:3456/0 | ||
ENV DONATIONS_REDIS_MAXIDLE 3 | ||
ENV DONATIONS_REDIS_IDLETIMEOUTSECONDS 240 | ||
|
||
ENV DONATIONS_SENTRY_URL "" | ||
ENV DONATIONS_NEWRELIC_KEY "" | ||
ENV DONATIONS_NEWRELIC_APPNAME "" | ||
|
||
ENV DONATIONS_BASICAUTH_USERNAME "" | ||
ENV DONATIONS_BASICAUTH_PASSWORD "" | ||
|
||
CMD /go/bin/donations start --bind 0.0.0.0 --port 8888 --fast --config /go/src/github.com/topfreegames/donations/config/default.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// donations | ||
// https://github.com/topfreegames/donations | ||
// | ||
// Licensed under the MIT license: | ||
// http://www.opensource.org/licenses/mit-license | ||
// Copyright © 2016 Top Free Games <backend@tfgco.com> | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/topfreegames/donations/api" | ||
"github.com/topfreegames/donations/log" | ||
"github.com/uber-go/zap" | ||
) | ||
|
||
var host string | ||
var port int | ||
var debug bool | ||
var quiet bool | ||
var fast bool | ||
var configFile string | ||
|
||
// startCmd represents the start command | ||
var startCmd = &cobra.Command{ | ||
Use: "start", | ||
Short: "starts the donations API server", | ||
Long: `Starts donations server with the specified arguments. You can use | ||
environment variables to override configuration keys.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
ll := zap.InfoLevel | ||
if debug { | ||
ll = zap.DebugLevel | ||
} | ||
if quiet { | ||
ll = zap.ErrorLevel | ||
} | ||
l := zap.New( | ||
zap.NewJSONEncoder(), // drop timestamps in tests | ||
ll, | ||
) | ||
|
||
cmdL := l.With( | ||
zap.String("source", "startCmd"), | ||
zap.String("operation", "Run"), | ||
zap.String("host", host), | ||
zap.Int("port", port), | ||
zap.Bool("debug", debug), | ||
) | ||
|
||
log.D(cmdL, "Creating application...") | ||
app, err := api.GetApp( | ||
host, | ||
port, | ||
configFile, | ||
debug, | ||
l, | ||
false, | ||
fast, | ||
) | ||
|
||
if err != nil { | ||
log.E(cmdL, "Application failed to start.", func(cm log.CM) { | ||
cm.Write(zap.Error(err)) | ||
}) | ||
os.Exit(1) | ||
} | ||
log.D(cmdL, "Application created successfully.") | ||
|
||
log.I(cmdL, fmt.Sprintf("Application started successfully at %s:%d", host, port)) | ||
app.Start() | ||
}, | ||
} | ||
|
||
func init() { | ||
RootCmd.AddCommand(startCmd) | ||
|
||
startCmd.Flags().StringVarP(&host, "bind", "b", "0.0.0.0", "Host to bind donations to") | ||
startCmd.Flags().IntVarP(&port, "port", "p", 8888, "Port to bind donations to") | ||
startCmd.Flags().StringVarP(&configFile, "config", "c", "./config/default.yaml", "Configuration path") | ||
startCmd.Flags().BoolVarP(&debug, "debug", "d", false, "Debug mode") | ||
startCmd.Flags().BoolVarP(&quiet, "quiet", "q", false, "Quiet mode (log level error)") | ||
startCmd.Flags().BoolVarP(&fast, "fast", "f", false, "Use FastHTTP as the Engine. If false, the net/http engine will be used") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters