Commit 5b750d06 authored by Nico Baruna Putra's avatar Nico Baruna Putra

change to check API method

parent 8642faf6
...@@ -3,10 +3,10 @@ module shell/tools/pm2 ...@@ -3,10 +3,10 @@ module shell/tools/pm2
go 1.16 go 1.16
require ( require (
github.com/hpcloud/tail v1.0.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 // indirect github.com/hpcloud/tail v1.0.0
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
) )
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 h1:LOlKVhfDyahgmqa97awczplwkjzNaELFg3zRIJ13RYo= golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
......
...@@ -5,8 +5,10 @@ import ( ...@@ -5,8 +5,10 @@ import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"log" "log"
"net/http"
"os/exec" "os/exec"
"strings" "strings"
"time"
"github.com/hpcloud/tail" "github.com/hpcloud/tail"
"gopkg.in/gomail.v2" "gopkg.in/gomail.v2"
...@@ -19,7 +21,9 @@ const CONFIG_AUTH_EMAIL = "truckscale_app@banpuindo.co.id" ...@@ -19,7 +21,9 @@ const CONFIG_AUTH_EMAIL = "truckscale_app@banpuindo.co.id"
const CONFIG_AUTH_PASSWORD = "" const CONFIG_AUTH_PASSWORD = ""
const ShellToUse = "bash" const ShellToUse = "bash"
const MYFILE = "CHaT-API-error1.log" const MYFILE = "CHaT-API-error1.log"
const KEYWORD = "ConnectionAcquireTimeoutError" const KEYWORD = "SequelizeConnectionAcquireTimeoutError"
const API_URL = "domains"
const BASE_URL = "https://chat-beuat.banpuindo.co.id/"
var statSize int64 var statSize int64
...@@ -53,7 +57,29 @@ func banner() { ...@@ -53,7 +57,29 @@ func banner() {
func main() { func main() {
banner() banner()
readFile(MYFILE) //readFile(MYFILE)
checkApi()
for range time.Tick(time.Second * 10) {
checkApi()
}
}
func checkApi() {
var flag = 0
response, err := http.Get(BASE_URL + API_URL)
if err != nil {
fmt.Print(err.Error())
sendMail("API not response")
Native()
//os.Exit(1)
}
if response.StatusCode != 200 || flag == 1 {
sendMail("API not response")
Native()
}
fmt.Println(response.StatusCode)
} }
func Shellout(command string) (error, string, string) { func Shellout(command string) (error, string, string) {
......
{ {
"apps" : [{ "apps" : [{
"name" : "service", "name" : "pm2",
"script" : "./index.go" "script" : "./pm2"
}] }]
} }
\ No newline at end of file
No preview for this file type
exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2 exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 2exit status 1exit status 1exit status 1exit status 1exit status 1
\ No newline at end of file \ No newline at end of file
File added
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment