Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: perf/go/perf_migratedb/main.go

Issue 659943006: Do not forget to call `defer glog.Flush()` in our applications (Closed) Base URL: https://skia.googlesource.com/buildbot@master
Patch Set: revert titletool changes Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « perf/go/logserver/main.go ('k') | perf/go/skiaperf/main.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 package main 1 package main
2 2
3 // Executes database migrations to the latest target version. In production this 3 // Executes database migrations to the latest target version. In production this
4 // requires the root password for MySQL. The user will be prompted for that so 4 // requires the root password for MySQL. The user will be prompted for that so
5 // it is not entered via the command line. 5 // it is not entered via the command line.
6 6
7 import ( 7 import (
8 "bufio" 8 "bufio"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
11 "os" 11 "os"
12 "strings" 12 "strings"
13 13
14 "github.com/golang/glog" 14 "github.com/golang/glog"
15 "skia.googlesource.com/buildbot.git/go/database" 15 "skia.googlesource.com/buildbot.git/go/database"
16 "skia.googlesource.com/buildbot.git/perf/go/db" 16 "skia.googlesource.com/buildbot.git/perf/go/db"
17 ) 17 )
18 18
19 func main() { 19 func main() {
20 defaultConnStr := strings.Replace(db.DB_CONN_TMPL, "%s", "root", 1) 20 defaultConnStr := strings.Replace(db.DB_CONN_TMPL, "%s", "root", 1)
21 21
22 // flags 22 // flags
23 dbConnString := flag.String("db_conn_string", defaultConnStr, "\n\tDatab ase string to open connect to the MySQL database. "+ 23 dbConnString := flag.String("db_conn_string", defaultConnStr, "\n\tDatab ase string to open connect to the MySQL database. "+
24 "\n\tNeeds to follow the format of the golang-mysql driver (http s://github.com/go-sql-driver/mysql."+ 24 "\n\tNeeds to follow the format of the golang-mysql driver (http s://github.com/go-sql-driver/mysql."+
25 "\n\tIf the string contains %s the user will be prompted to ente r a password which will then be used for subtitution.") 25 "\n\tIf the string contains %s the user will be prompted to ente r a password which will then be used for subtitution.")
26 26
27 flag.Parse() 27 flag.Parse()
28 defer glog.Flush()
28 29
29 var connectionStr = *dbConnString 30 var connectionStr = *dbConnString
30 31
31 // if it contains formatting information read the password from stdin. 32 // if it contains formatting information read the password from stdin.
32 if strings.Contains(connectionStr, "%s") { 33 if strings.Contains(connectionStr, "%s") {
33 glog.Infof("Using connection string: %s", connectionStr) 34 glog.Infof("Using connection string: %s", connectionStr)
34 reader := bufio.NewReader(os.Stdin) 35 reader := bufio.NewReader(os.Stdin)
35 fmt.Print("Enter password for MySQL: ") 36 fmt.Print("Enter password for MySQL: ")
36 password, err := reader.ReadString('\n') 37 password, err := reader.ReadString('\n')
37 if err != nil { 38 if err != nil {
(...skipping 21 matching lines...) Expand all
59 if dbVersion < maxDBVersion { 60 if dbVersion < maxDBVersion {
60 glog.Infof("Migrating to version: %d", maxDBVersion) 61 glog.Infof("Migrating to version: %d", maxDBVersion)
61 err = vdb.Migrate(maxDBVersion) 62 err = vdb.Migrate(maxDBVersion)
62 if err != nil { 63 if err != nil {
63 glog.Fatalf("Unable to retrieve database version. Error: %s", err.Error()) 64 glog.Fatalf("Unable to retrieve database version. Error: %s", err.Error())
64 } 65 }
65 } 66 }
66 67
67 glog.Infoln("Database migration finished.") 68 glog.Infoln("Database migration finished.")
68 } 69 }
OLDNEW
« no previous file with comments | « perf/go/logserver/main.go ('k') | perf/go/skiaperf/main.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698