Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Isabella Skořepová
travian
Commits
bf14f266
Unverified
Commit
bf14f266
authored
Sep 17, 2017
by
Isabella Skořepová
Browse files
Do not crash on error in bot
🏃
parent
87eed40a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/index.js
View file @
bf14f266
...
@@ -8,6 +8,10 @@ async function readCredentials() {
...
@@ -8,6 +8,10 @@ async function readCredentials() {
return
JSON
.
parse
(
await
promisify
(
fs
.
readFile
)(
'
creds.json
'
,
'
utf-8
'
))
return
JSON
.
parse
(
await
promisify
(
fs
.
readFile
)(
'
creds.json
'
,
'
utf-8
'
))
}
}
function
timeout
(
ms
)
{
return
new
Promise
(
res
=>
setTimeout
(
res
,
ms
))
}
console
.
log
(
'
starting
'
)
console
.
log
(
'
starting
'
)
;(
async
()
=>
{
;(
async
()
=>
{
const
args
=
await
Travian
.
generateArgs
({
const
args
=
await
Travian
.
generateArgs
({
...
@@ -22,8 +26,15 @@ console.log('starting')
...
@@ -22,8 +26,15 @@ console.log('starting')
while
(
true
)
{
while
(
true
)
{
delete
require
.
cache
[
require
.
resolve
(
'
./travian
'
)]
delete
require
.
cache
[
require
.
resolve
(
'
./travian
'
)]
delete
require
.
cache
[
require
.
resolve
(
'
./bot
'
)]
delete
require
.
cache
[
require
.
resolve
(
'
./bot
'
)]
// eslint-disable-next-line global-require
try
{
await
require
(
'
./bot
'
).
bot
(
require
(
'
./travian
'
).
travianImpl
(...
args
))
// eslint-disable-next-line global-require
await
require
(
'
./bot
'
).
bot
(
require
(
'
./travian
'
).
travianImpl
(...
args
))
}
catch
(
e
)
{
console
.
error
(
'
Detected problem while running bot...
'
)
console
.
error
(
e
)
console
.
error
(
"
Sleeping for 5 seconds so that it doesn't use whole CPU
"
)
await
timeout
(
5000
)
}
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
travian
.
close
()
travian
.
close
()
...
...
Write
Preview
Supports
Markdown
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