mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-24 19:02:07 +00:00
add metrics for ASpell workers
This commit is contained in:
parent
ed33cd59b7
commit
7936269804
2 changed files with 6 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
child_process = require("child_process")
|
||||
logger = require 'logger-sharelatex'
|
||||
metrics = require('metrics-sharelatex')
|
||||
|
||||
BATCH_SIZE = 100
|
||||
|
||||
|
@ -9,9 +10,11 @@ class ASpellWorker
|
|||
@count = 0
|
||||
@pipe = child_process.spawn("aspell", ["pipe", "-t", "--encoding=utf-8", "-d", language])
|
||||
logger.log process: @pipe.pid, lang: @language, "starting new aspell worker"
|
||||
metrics.inc "aspellWorker-start-" + @language
|
||||
@pipe.on 'exit', () =>
|
||||
@state = 'killed'
|
||||
logger.log process: @pipe.pid, lang: @language, "aspell worker has exited"
|
||||
metrics.inc "aspellWorker-exit-" + @language
|
||||
@pipe.on 'error', (err) =>
|
||||
@state = 'error'
|
||||
@callback err, []
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
ASpellWorker = require "./ASpellWorker"
|
||||
_ = require "underscore"
|
||||
logger = require 'logger-sharelatex'
|
||||
metrics = require('metrics-sharelatex')
|
||||
|
||||
class ASpellWorkerPool
|
||||
MAX_REQUESTS: 100*1024
|
||||
|
@ -18,12 +19,14 @@ class ASpellWorkerPool
|
|||
worker.pipe.on 'exit', () =>
|
||||
@cleanup()
|
||||
@PROCESS_POOL.push(worker)
|
||||
metrics.gauge 'aspellWorkerPool-size', @PROCESS_POOL.length
|
||||
return worker
|
||||
|
||||
cleanup: () ->
|
||||
active = @PROCESS_POOL.filter (worker) ->
|
||||
worker.state != 'killed'
|
||||
@PROCESS_POOL = active
|
||||
metrics.gauge 'aspellWorkerPool-size', @PROCESS_POOL.length
|
||||
|
||||
check: (language, words, timeout, callback) ->
|
||||
# look for an existing process in the pool
|
||||
|
|
Loading…
Reference in a new issue