fix(oracle): select 1 from dual
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0d8c7602e7
commit
fd5aa6793b
@ -6,7 +6,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,27 +44,18 @@ LOOP:
|
|||||||
|
|
||||||
switch databaseURL.Scheme {
|
switch databaseURL.Scheme {
|
||||||
case "oracle":
|
case "oracle":
|
||||||
row := sqlDB.QueryRowContext(queryCtx, "SELECT INSTANCE_NAME, STATUS, DATABASE_STATUS FROM V$INSTANCE WHERE INSTANCE_NAME=$1", databaseURL.Path)
|
row := sqlDB.QueryRowContext(queryCtx, "SELECT 1 FROM dual")
|
||||||
|
|
||||||
var instaceName string
|
var n int
|
||||||
var instanceStatus string
|
err := row.Scan(&n)
|
||||||
var databaseStatus string
|
|
||||||
|
|
||||||
err := row.Scan(instaceName, instanceStatus, databaseStatus)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "%s: %s\n", time.Now().String(), err.Error())
|
fmt.Fprintf(os.Stderr, "%s: %s\n", time.Now().String(), err.Error())
|
||||||
ticker.Reset(period)
|
ticker.Reset(period)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.ToUpper(instanceStatus) != "OPEN" {
|
if n != 1 {
|
||||||
fmt.Fprintf(os.Stderr, "%s: Instance status is not open: %s\n", time.Now().String(), instanceStatus)
|
fmt.Fprintf(os.Stderr, "%s: Returned value not 1\n", time.Now().String())
|
||||||
ticker.Reset(period)
|
|
||||||
continue LOOP
|
|
||||||
}
|
|
||||||
|
|
||||||
if strings.ToUpper(databaseStatus) != "OPEN" {
|
|
||||||
fmt.Fprintf(os.Stderr, "%s: Database status is not active: %s\n", time.Now().String(), databaseStatus)
|
|
||||||
ticker.Reset(period)
|
ticker.Reset(period)
|
||||||
continue LOOP
|
continue LOOP
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user