Release logging to sentry

This commit is contained in:
Howl 2016-06-17 10:34:53 +02:00
parent 427f2ff890
commit b3e31734f5
4 changed files with 17 additions and 1 deletions

View File

@ -23,6 +23,7 @@ func Start(conf common.Conf, dbO *sql.DB) *gin.Engine {
if conf.SentryDSN != "" { if conf.SentryDSN != "" {
ravenClient, err := raven.New(conf.SentryDSN) ravenClient, err := raven.New(conf.SentryDSN)
ravenClient.SetRelease(common.Version)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
} else { } else {

View File

@ -78,7 +78,7 @@ func MetaUpdateGET(md common.MethodData) common.CodeMessager {
if !execCommand("go", "get", "-v", "-u", "-d") { if !execCommand("go", "get", "-v", "-u", "-d") {
return return
} }
if !execCommand("go", "build", "-v", "-o", "api") { if !execCommand("bash", "-c", "go build -v -ldflags \"-X main.Version=`git rev-parse HEAD`\" -o api") {
return return
} }

View File

@ -6,6 +6,10 @@ import (
"github.com/thehowl/conf" "github.com/thehowl/conf"
) )
// Version is the git hash of the application. Do not edit. This is
// automatically set using -ldflags during build time.
var Version string
// Conf is the configuration file data for the ripple API. // Conf is the configuration file data for the ripple API.
// Conf uses https://github.com/thehowl/conf // Conf uses https://github.com/thehowl/conf
type Conf struct { type Conf struct {

11
main.go
View File

@ -17,12 +17,23 @@ import (
_ "github.com/go-sql-driver/mysql" _ "github.com/go-sql-driver/mysql"
) )
// Version is the git hash of the application. Do not edit. This is
// automatically set using -ldflags during build time.
var Version string
func init() { func init() {
log.SetFlags(log.Ltime) log.SetFlags(log.Ltime)
log.SetPrefix(fmt.Sprintf("%d|", syscall.Getpid())) log.SetPrefix(fmt.Sprintf("%d|", syscall.Getpid()))
common.Version = Version
} }
func main() { func main() {
fmt.Print("Ripple API")
if Version != "" {
fmt.Print("; git commit hash: ", Version)
}
fmt.Println()
conf, halt := common.Load() conf, halt := common.Load()
if halt { if halt {
return return