Commit 01945620 authored by Nico Baruna Putra's avatar Nico Baruna Putra

create .env

parent 49e84aa6
CONFIG_SMTP_HOST="internalmail.banpuindo.co.id"
CONFIG_SMTP_PORT="25"
CONFIG_SENDER_NAME="Nico Baruna <nico_putra@banpuindo.co.id>"
CONFIG_AUTH_EMAIL="truckscale_app@banpuindo.co.id"
CONFIG_AUTH_PASSWORD=""
ShellToUse="bash"
MYFILE="CHaT-API-error1.log"
KEYWORD="SequelizeConnectionAcquireTimeoutError"
API_URL="status"
BASE_URL="https://moca-be.banpuindo.co.id/"
\ No newline at end of file
......@@ -5,6 +5,7 @@ go 1.16
require (
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hpcloud/tail v1.0.0
github.com/joho/godotenv v1.5.1 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/fsnotify.v1 v1.4.7 // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
......
......@@ -2,6 +2,8 @@ github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nos
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/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
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=
......
......@@ -6,27 +6,21 @@ import (
"io/ioutil"
"log"
"net/http"
"os"
"os/exec"
"strconv"
"time"
"github.com/joho/godotenv"
"gopkg.in/gomail.v2"
)
const CONFIG_SMTP_HOST = "internalmail.banpuindo.co.id"
const CONFIG_SMTP_PORT = 25
const CONFIG_SENDER_NAME = "Nico Baruna <nico_putra@banpuindo.co.id>"
const CONFIG_AUTH_EMAIL = "truckscale_app@banpuindo.co.id"
const CONFIG_AUTH_PASSWORD = ""
const ShellToUse = "bash"
const MYFILE = "CHaT-API-error1.log"
const KEYWORD = "SequelizeConnectionAcquireTimeoutError"
const API_URL = "domains"
const BASE_URL = "https://chat-beuat.banpuindo.co.id/"
var statSize int64
const ShellToUse = "bash"
func sendMail(errorMsg string) {
fmt.Println("Try sending email to " + CONFIG_SENDER_NAME)
fmt.Println("Try sending email to " + os.Getenv("CONFIG_SENDER_NAME"))
m := gomail.NewMessage()
m.SetHeader("From", "nico.baruna@gmail.com")
m.SetHeader("To", "nico.baruna@gmail.com", "nico_putra@banpuindo.co.id")
......@@ -34,8 +28,9 @@ func sendMail(errorMsg string) {
m.SetHeader("Subject", "Error found in Chat BE UAT!")
m.SetBody("text/html", "Hello <b>Nico</b> ! we found and error "+errorMsg)
//m.Attach("/home/Alex/lolcat.jpg")
d := gomail.NewDialer(CONFIG_SMTP_HOST, CONFIG_SMTP_PORT, CONFIG_AUTH_EMAIL, CONFIG_AUTH_PASSWORD)
portStr := os.Getenv("CONFIG_SMTP_PORT")
port, _ := strconv.Atoi(portStr)
d := gomail.NewDialer(os.Getenv("CONFIG_SMTP_HOST"), port, os.Getenv("CONFIG_AUTH_EMAIL"), os.Getenv("CONFIG_AUTH_PASSWORD"))
// Send the email to Bob, Cora and Dan.
if err := d.DialAndSend(m); err != nil {
......@@ -56,7 +51,13 @@ func banner() {
func main() {
//banner()
//readFile(MYFILE)
fmt.Println("Watcher v.1.2.1")
err := godotenv.Load()
if err != nil {
log.Fatalf("unable to load .env file: %e", err)
}
fmt.Println("Watcher v.1.2.2")
checkApi()
for range time.Tick(time.Second * 10) {
checkApi()
......@@ -66,7 +67,7 @@ func main() {
func checkApi() {
response, err := http.Get(BASE_URL + API_URL)
response, err := http.Get(os.Getenv("BASE_URL") + os.Getenv("API_URL"))
if err != nil {
fmt.Println("ERROR NIH BOS!, KONEKSI PUTUS , KEMUNGKINAN SERVICE MATI")
......
File deleted
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 1exit status 1
\ No newline at end of file
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 1exit status 1exit status 1exit status 1exit status 1
\ No newline at end of file
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