Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대휘
/
Do-gether
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김대휘
2020-07-04 23:37:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
26d296907c7d53cf880be49ca93d66ef794d4d7a
26d29690
1 parent
a1fe7a4e
DB 연결오류 3차수정
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
server.js
server.js
View file @
26d2969
...
...
@@ -21,25 +21,25 @@ const connection = mysql.createConnection({
database
:
conf
.
database
,
});
// connection.connect();
//
function handleDisconnect() {
//
connection.connect(function (err) {
//
if (err) {
//
console.log("error when connecting to db:", err);
//
setTimeout(handleDisconnect, 4000);
//
}
//
});
//
connection.on("error", function (err) {
//
console.log("db error", err);
//
if (err.code === "PROTOCOL_CONNECTION_LOST") {
//
return handleDisconnect();
//
} else {
//
throw err;
//
}
//
});
//
}
//
handleDisconnect();
function
handleDisconnect
()
{
connection
.
connect
(
function
(
err
)
{
if
(
err
)
{
console
.
log
(
"error when connecting to db:"
,
err
);
setTimeout
(
handleDisconnect
,
4000
);
}
});
connection
.
on
(
"error"
,
function
(
err
)
{
console
.
log
(
"db error"
,
err
);
if
(
err
.
code
===
"PROTOCOL_CONNECTION_LOST"
)
{
return
handleDisconnect
();
}
else
{
throw
err
;
}
});
}
handleDisconnect
();
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
...
...
Please
register
or
login
to post a comment