Skip to content

Commit df069f8

Browse files
infinite loop
1 parent d3529aa commit df069f8

File tree

6 files changed

+28
-3
lines changed

6 files changed

+28
-3
lines changed

.env

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
SLEEP=5
12
MAGASIN=Ramonville
23
LOGIN=mail@example.com
34
PASSWORD=xxxxxxxx

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
```bash
2-
docker run --rm -e MAGASIN=Ramonville -e LOGIN=mail@example.com -e PASSWORD=xxxxxxxx -e MAILER_HOST=localhost -e MAILER_PORT=25 -e MAILER_AUTH_USER=mail@example.com -e MAILER_AUTH_PASS=xxxxxxxx -e MAIL_FROM=mail@example.com -e MAIL_TO=mail@example.com sebastienprudhomme/chronodrive
2+
docker run --rm -e SLEEP=5 MAGASIN=Ramonville -e LOGIN=mail@example.com -e PASSWORD=xxxxxxxx -e MAILER_HOST=localhost -e MAILER_PORT=25 -e MAILER_AUTH_USER=mail@example.com -e MAILER_AUTH_PASS=xxxxxxxx -e MAIL_FROM=mail@example.com -e MAIL_TO=mail@example.com sebastienprudhomme/chronodrive
33
```

package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"bottleneck": "2.19.5",
1313
"nodemailer": "6.4.4",
1414
"puppeteer": "2.1.1",
15+
"sleepjs": "3.0.1",
1516
"winston": "3.2.1",
1617
"winston-console-format": "1.0.5"
1718
},

src/chronodrive.js

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ async function crawlChronodrive () {
6262
}
6363

6464
await mailerTransporter.sendMail(mail)
65+
66+
process.exit(0)
6567
}
6668
} catch (error) {
6769
winston.log({ level: 'error', message: error })

src/index.js

+18-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,29 @@ const { initWinston } = require('./winston')
44
// Chronodrive
55
const { crawlChronodrive } = require('./chronodrive')
66

7+
// SleepJS
8+
const { sleepMinutes } = require('sleepjs')
9+
10+
// Exit function
11+
function exitProcess() {
12+
process.exit(0)
13+
}
14+
715
// Main function
816
async function main () {
17+
process.on('SIGINT', exitProcess)
18+
process.on('SIGTERM', exitProcess)
19+
920
// Init Winston
1021
initWinston()
1122

12-
// Crawl Chronodrive
13-
crawlChronodrive()
23+
while (true) {
24+
// Crawl Chronodrive
25+
crawlChronodrive()
26+
27+
// Sleep
28+
await sleepMinutes(process.env.SLEEP)
29+
}
1430
}
1531

1632
main()

0 commit comments

Comments
 (0)