Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
P
PM2 watcher
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nico Baruna Putra
PM2 watcher
Commits
f36d5bae
Commit
f36d5bae
authored
Oct 25, 2021
by
Nico Baruna Putra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new way of checking log
parent
f4798650
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
46 deletions
+81
-46
CHaT-API-error1.log
CHaT-API-error1.log
+47
-14
go.mod
go.mod
+4
-0
go.sum
go.sum
+8
-0
index.go
index.go
+22
-32
No files found.
CHaT-API-error1.log
View file @
f36d5bae
...
...
@@ -2352,7 +2352,7 @@ TypeError: Cannot read property 'stack' of undefined
TypeError
:
Cannot
read
property
'map'
of
null
at
Object
.
flush
(
/
var
/
www
/
webapps
/
caraka
/
source
/
dist
/
src
/
utils
/
CacheHelper
.
js
:
216
:
27
)
at
<
anonymous
>
(
node
:
100753
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
100753
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
100753
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
64
)
...
...
@@ -2421,7 +2421,7 @@ TypeError: Cannot read property 'stack' of undefined
TypeError
:
Cannot
read
property
'map'
of
null
at
Object
.
flush
(
/
var
/
www
/
webapps
/
caraka
/
source
/
dist
/
src
/
utils
/
CacheHelper
.
js
:
216
:
27
)
at
<
anonymous
>
(
node
:
125174
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
125174
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
125174
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
73
)
...
...
@@ -2430,37 +2430,37 @@ TypeError: Cannot read property 'map' of null
at
Object
.
flush
(
/
var
/
www
/
webapps
/
caraka
/
source
/
dist
/
src
/
utils
/
CacheHelper
.
js
:
216
:
27
)
at
<
anonymous
>
(
node
:
125174
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
78
)
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
68
)
(
node
:
99544
)
[
DEP0018
]
DeprecationWarning
:
Unhandled
promise
rejections
are
deprecated
.
In
the
future
,
promise
rejections
that
are
not
handled
will
terminate
the
Node
.
js
process
with
a
non
-
zero
exit
code
.
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
83
)
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
97
)
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
104
)
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
99544
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
106
)
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
TypeError
:
Cannot
read
property
'stack'
of
undefined
...
...
@@ -2472,7 +2472,7 @@ TypeError: Cannot read property 'stack' of undefined
TypeError
:
Cannot
read
property
'map'
of
null
at
Object
.
flush
(
/
var
/
www
/
webapps
/
caraka
/
source
/
dist
/
src
/
utils
/
CacheHelper
.
js
:
216
:
27
)
at
<
anonymous
>
(
node
:
129961
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
129961
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
129961
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
3
)
...
...
@@ -2481,7 +2481,7 @@ TypeError: Cannot read property 'map' of null
at
Object
.
flush
(
/
var
/
www
/
webapps
/
caraka
/
source
/
dist
/
src
/
utils
/
CacheHelper
.
js
:
216
:
27
)
at
<
anonymous
>
(
node
:
129961
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
4
)
(
node
:
129961
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
129961
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
129961
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
5
)
...
...
@@ -2500,7 +2500,7 @@ TypeError: Cannot read property 'map' of null
at
<
anonymous
>
(
node
:
23395
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
314
)
(
node
:
23395
)
[
DEP0018
]
DeprecationWarning
:
Unhandled
promise
rejections
are
deprecated
.
In
the
future
,
promise
rejections
that
are
not
handled
will
terminate
the
Node
.
js
process
with
a
non
-
zero
exit
code
.
(
node
:
23395
)
UnhandledPromiseRejectionWarning
:
SequelizeConnectionAcquireTimeoutError
:
Operation
timeout
(
node
:
23395
)
UnhandledPromiseRejectionWarning
:
:
Operation
timeout
at
pool
.
acquire
.
catch
.
error
(
/
var
/
www
/
webapps
/
caraka
/
source
/
node_modules
/
sequelize
/
lib
/
dialects
/
abstract
/
connection
-
manager
.
js
:
289
:
52
)
at
<
anonymous
>
(
node
:
23395
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
543
)
...
...
@@ -2531,3 +2531,36 @@ TypeError: Cannot read property 'map' of null
at
Object
.
flush
(
/
var
/
www
/
webapps
/
caraka
/
source
/
dist
/
src
/
utils
/
CacheHelper
.
js
:
216
:
27
)
at
<
anonymous
>
(
node
:
23395
)
UnhandledPromiseRejectionWarning
:
Unhandled
promise
rejection
.
This
error
originated
either
by
throwing
inside
of
an
async
function
without
a
catch
block
,
or
by
rejecting
a
promise
which
was
not
handled
with
.
catch
()
.
(
rejection
id
:
547
)
alskdjk
laksdalskdjlasd
jlasdj
lasdk
jasldkj
alskdjk
lkdfjslkf
jsldkfj
lsdkjflskdfj
lsdkjf
lsdjk
flsdjf
lsdfj
lsdfj
lsdfj
sldkfj
sldkfj
asdjhasljdh
asjdh
kasjdh
kasdh
kasjdh
kasjdh
kajsdh
kasdh
kasdh
kasjdhka
hdskashdkjasdhkh
,
aljshdklahsd
klajdh
kajdh
kajsdhkjhkadh
kasjd
hkj
hdskashdkjasdhkhaksjalk
deprecated
alsjdhajklsdh
kasjdhkasjdhkasjdh
kasjdhkasjdh
kasjdh
kajsdhkasjdh
kasjdh
kasjdh
skdh
asdaasdasdasd
start
:=
stat
.
Size
()
-
statSizess
sdfsdf
sdf
dsf
sdfs
df
sdf
sdf
sdfsdf
sdf
sdf
sdf
sdf
sdf
sdf
sdfsdfsdfsdf
zxcdsdfdf
zsfsfsdf
asdasd
asdaasdasdasd
asdadas
asdasd
asdaasdasdasd
asdadas
asdaasdasdasd
asdasdas
asdaasdasdasd
adadasdsa
SequelizeConnectionAcquireTimeoutError
adsasdasd
asd
asd
asd
asd
asdasd
asd
as
asd
asdadsad
go.mod
View file @
f36d5bae
...
...
@@ -3,6 +3,10 @@ module shell/tools/pm2
go 1.16
require (
github.com/hpcloud/tail v1.0.0 // indirect
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 // 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 // indirect
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
)
go.sum
View file @
f36d5bae
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
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.0.0-20211020174200-9d6173849985/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/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
index.go
View file @
f36d5bae
...
...
@@ -5,22 +5,21 @@ import (
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"strings"
"time"
"github.com/hpcloud/tail"
"gopkg.in/gomail.v2"
)
const
CONFIG_SMTP_HOST
=
"
I
nternalmail.banpuindo.co.id"
const
CONFIG_SMTP_HOST
=
"
i
nternalmail.banpuindo.co.id"
const
CONFIG_SMTP_PORT
=
25
const
CONFIG_SENDER_NAME
=
"Nico Baruna <nico
.baruna@gmail.com
>"
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
=
"
/var/www/webapps/caraka/.pm2/logs/CHaT-API-error
.log"
const
KEYWORD
=
"
SequelizeConnectionAcquireTimeoutError:
"
const
MYFILE
=
"
CHaT-API-error1
.log"
const
KEYWORD
=
"
ConnectionAcquireTimeoutError
"
var
statSize
int64
...
...
@@ -28,7 +27,7 @@ func sendMail(errorMsg string) {
fmt
.
Println
(
"Try sending email to "
+
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"
)
m
.
SetHeader
(
"To"
,
"nico.baruna@gmail.com"
,
"nico_putra@banpuindo.co.id"
,
"manandit@gmail.com"
)
//m.SetAddressHeader("Cc", "dan@example.com", "Dan")
m
.
SetHeader
(
"Subject"
,
"Error found in Chat BE UAT!"
)
m
.
SetBody
(
"text/html"
,
"Hello <b>Nico</b> ! we found and error "
+
errorMsg
)
...
...
@@ -54,13 +53,7 @@ func banner() {
func
main
()
{
banner
()
//sendMail()
c
:=
time
.
Tick
(
10
*
time
.
Second
)
statSize
=
0
for
_
=
range
c
{
fmt
.
Println
(
"Start Scanning error log"
)
readFile
(
MYFILE
)
}
readFile
(
MYFILE
)
}
func
Shellout
(
command
string
)
(
error
,
string
,
string
)
{
...
...
@@ -85,25 +78,22 @@ func Native() {
}
func
readFile
(
fname
string
)
{
file
,
err
:=
os
.
Open
(
fname
)
if
err
!=
nil
{
panic
(
err
)
}
defer
file
.
Close
()
stat
,
err
:=
os
.
Stat
(
fname
)
buf
:=
make
([]
byte
,
int64
(
stat
.
Size
()))
if
statSize
<
int64
(
stat
.
Size
())
{
statSize
=
int64
(
stat
.
Size
())
start
:=
stat
.
Size
()
-
statSize
_
,
err
=
file
.
ReadAt
(
buf
,
start
)
if
err
==
nil
&&
strings
.
Contains
(
string
(
buf
),
KEYWORD
)
{
fmt
.
Println
(
"error found at "
+
time
.
Now
()
.
String
())
Native
()
sendMail
(
string
(
buf
))
t
,
err
:=
tail
.
TailFile
(
MYFILE
,
tail
.
Config
{
Follow
:
true
,
Poll
:
true
})
flag
:=
0
if
err
==
nil
{
for
line
:=
range
t
.
Lines
{
fmt
.
Println
(
"==NEW line detected=="
)
fmt
.
Println
(
line
.
Text
)
if
strings
.
Contains
(
line
.
Text
,
KEYWORD
)
{
fmt
.
Println
(
"ERROR FOUND"
)
Native
()
sendMail
(
line
.
Text
)
}
flag
++
fmt
.
Println
(
"end"
)
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment