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
e9355dee
Commit
e9355dee
authored
Oct 19, 2021
by
nico baruna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add shell execute
parent
82dc924f
Pipeline
#23030
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
6 deletions
+20
-6
index.go
index.go
+20
-6
No files found.
index.go
View file @
e9355dee
package
main
package
main
import
(
import
(
"bytes"
"fmt"
"fmt"
"io/ioutil"
"io/ioutil"
"log"
"log"
...
@@ -17,9 +18,9 @@ const CONFIG_SMTP_PORT = 25
...
@@ -17,9 +18,9 @@ const CONFIG_SMTP_PORT = 25
const
CONFIG_SENDER_NAME
=
"Nico Baruna <nico.baruna@gmail.com>"
const
CONFIG_SENDER_NAME
=
"Nico Baruna <nico.baruna@gmail.com>"
const
CONFIG_AUTH_EMAIL
=
"truckscale_app@banpuindo.co.id"
const
CONFIG_AUTH_EMAIL
=
"truckscale_app@banpuindo.co.id"
const
CONFIG_AUTH_PASSWORD
=
""
const
CONFIG_AUTH_PASSWORD
=
""
const
ShellToUse
=
"bash"
const
MYFILE
=
"
/var/www/webapps/caraka/.pm2/logs/
CHaT-API-error.log"
const
MYFILE
=
"CHaT-API-error.log"
const
KEYWORD
=
"
SequelizeConnectionAcquireTimeoutError
"
const
KEYWORD
=
"
a
"
var
statSize
int
var
statSize
int
...
@@ -61,12 +62,25 @@ func main() {
...
@@ -61,12 +62,25 @@ func main() {
}
}
}
}
func
Shellout
(
command
string
)
(
error
,
string
,
string
)
{
var
stdout
bytes
.
Buffer
var
stderr
bytes
.
Buffer
cmd
:=
exec
.
Command
(
ShellToUse
,
"-c"
,
command
)
cmd
.
Stdout
=
&
stdout
cmd
.
Stderr
=
&
stderr
err
:=
cmd
.
Run
()
return
err
,
stdout
.
String
(),
stderr
.
String
()
}
func
Native
()
{
func
Native
()
{
out
,
err
:=
exec
.
Command
(
"pm2 restart 0"
)
.
Output
(
)
err
,
out
,
errout
:=
Shellout
(
"pm2 restart 0"
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Printf
(
"error: %v
\n
"
,
err
)
}
}
fmt
.
Printf
(
"The date is %s
\n
"
,
out
)
fmt
.
Println
(
"--- stdout ---"
)
fmt
.
Println
(
out
)
fmt
.
Println
(
"--- stderr ---"
)
fmt
.
Println
(
errout
)
}
}
func
readFile
(
fname
string
)
{
func
readFile
(
fname
string
)
{
...
...
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