diff options
| author | MeiMei <30769358+mei23@users.noreply.github.com> | 2019-11-07 00:02:18 +0900 |
|---|---|---|
| committer | syuilo <Syuilotan@yahoo.co.jp> | 2019-11-07 00:02:18 +0900 |
| commit | 873444c3c6f7e3b9ecb6cce569d8cdb3fa032012 (patch) | |
| tree | 30a52b7ac3025e92c0e9ce5c7028a96af83f7088 /src/queue/get-job-info.ts | |
| parent | Resolve #5582 (#5583) (diff) | |
| download | misskey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.tar.gz misskey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.tar.bz2 misskey-873444c3c6f7e3b9ecb6cce569d8cdb3fa032012.zip | |
APの統計とログの修正と強化 (#5585)
* Fix #5580
* Improve AP logging
Diffstat (limited to 'src/queue/get-job-info.ts')
| -rw-r--r-- | src/queue/get-job-info.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/queue/get-job-info.ts b/src/queue/get-job-info.ts new file mode 100644 index 0000000000..f601ae62d0 --- /dev/null +++ b/src/queue/get-job-info.ts @@ -0,0 +1,15 @@ +import * as Bull from 'bull'; + +export function getJobInfo(job: Bull.Job, increment = false) { + const age = Date.now() - job.timestamp; + + const formated = age > 60000 ? `${Math.floor(age / 1000 / 60)}m` + : age > 10000 ? `${Math.floor(age / 1000)}s` + : `${age}ms`; + + // onActiveとかonCompletedのattemptsMadeがなぜか0始まりなのでインクリメントする + const currentAttempts = job.attemptsMade + (increment ? 1 : 0); + const maxAttempts = job.opts ? job.opts.attempts : 0; + + return `id=${job.id} attempts=${currentAttempts}/${maxAttempts} age=${formated}`; +} |