setInterval only if in pm2
This commit is contained in:
parent
87eadcc9fa
commit
9e85cfaaec
15
src/gd.js
15
src/gd.js
|
@ -22,10 +22,17 @@ const SA_FILES = fs.readdirSync(path.join(__dirname, SA_PATH)).filter(v => v.end
|
|||
SA_FILES.flag = 0
|
||||
let SA_TOKENS = get_sa_batch()
|
||||
|
||||
setInterval(() => {
|
||||
SA_FILES.flag = 0
|
||||
SA_TOKENS = get_sa_batch()
|
||||
}, 1000 * 3600 * 12)
|
||||
if (is_pm2()) {
|
||||
setInterval(() => {
|
||||
SA_FILES.flag = 0
|
||||
SA_TOKENS = get_sa_batch()
|
||||
}, 1000 * 3600 * 12)
|
||||
}
|
||||
|
||||
// https://github.com/Leelow/is-pm2/blob/master/index.js
|
||||
function is_pm2 () {
|
||||
return 'PM2_HOME' in process.env || 'PM2_JSON_PROCESSING' in process.env || 'PM2_CLI' in process.env
|
||||
}
|
||||
|
||||
function get_sa_batch () {
|
||||
const new_flag = SA_FILES.flag + SA_BATCH_SIZE
|
||||
|
|
Loading…
Reference in New Issue