From fb4c7f7bbbbd73dc39a527ac554f2e1460afc5de Mon Sep 17 00:00:00 2001 From: dtookey Date: Fri, 29 Apr 2022 16:21:53 -0400 Subject: [PATCH] The mercury binary is now deployable and *should* run every morning at 2am --- build.sh | 2 +- deploy.sh | 11 +++++++++++ src/insight/insight-connect.go | 6 +++--- src/insight/insight-database.go | 7 ++++--- 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 deploy.sh diff --git a/build.sh b/build.sh index 5386151..09f881f 100644 --- a/build.sh +++ b/build.sh @@ -6,6 +6,6 @@ rm build/* go build -o ./build/mercury ./src -mercury_qb_path="/home/dtookey/work/clarity-reporting/qb/" ./build/mercury +mercury_qb_path="/home/dtookey/work/clarity-reporting/qb/" DB_CREDS="$(cat /home/dtookey/work/datastudio-db-creds.txt)" DB_HOST=data-connect.carolina.engineering ./build/mercury diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..3002051 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,11 @@ +#! /bin/bash + +cd /opt/go/src/mercury || exit + +rm build/* + +go build -o ./build/mercury ./src + +rsync -avP ./build/mercury data-connect.carolina.engineering:/home/dtookey/ +ssh data-connect.carolina.engineering "sudo mv /home/dtookey/mercury /usr/local/bin/" + diff --git a/src/insight/insight-connect.go b/src/insight/insight-connect.go index cc90bed..9fe46c8 100644 --- a/src/insight/insight-connect.go +++ b/src/insight/insight-connect.go @@ -125,15 +125,15 @@ func (ic *Interconnect) UpdateTimeEntries() { for _, userPtr := range *users { go ic.Client.GetTimeAllTimeEntriesForUserThroughDate(userPtr.Id, "2022-04-28", entryChan) coroutineCount++ - time.Sleep(200 * time.Millisecond) + time.Sleep(1000 * time.Millisecond) } - log.Printf("Currently working goroutines: %d\n", coroutineCount) + log.Printf("Currently pending goroutines: %d\n", coroutineCount) for coroutineCount > 0 { entries := <-entryChan ic.DBConnector.UpdateTimeEntries(entries) coroutineCount-- - log.Printf("Currently working goroutines: %d\n", coroutineCount) + log.Printf("Currently pending goroutines: %d\n", coroutineCount) } ic.DBConnector.ExecuteSqlScript("insight", "create-insight-contribution-table.sql") } diff --git a/src/insight/insight-database.go b/src/insight/insight-database.go index 069ca9d..2ad52b5 100644 --- a/src/insight/insight-database.go +++ b/src/insight/insight-database.go @@ -149,9 +149,10 @@ func (c *DBConnector) returnConnection(db *sql.DB) { ======================================================================================*/ func createDbConnection(database string) *sql.DB { - secret := getSecret("/home/dtookey/work/datastudio-db-creds.txt") - dbString := "clarity:%s@tcp(data-connect.carolina.engineering)/%s" - connectString := fmt.Sprintf(dbString, *secret, database) + cred := os.Getenv("DB_CREDS") + host := os.Getenv("DB_HOST") + dbString := "clarity:%s@tcp(%s)/%s" + connectString := fmt.Sprintf(dbString, cred, host, database) db, err := sql.Open("mysql", connectString) if err != nil {