私はルビーSinatra APIを起動する小さなドッカーイメージを実行しています。 APIのThポイントは、画像を受信し、スクリプトを使用してそれを前処理し、Tesseract OCRを使用して画像からテキストを戻すことです。H12ヒロクでリクエストタイムアウト503、その後200成功
私は、503エラーが発生し、テキストで300成功していますが、iosアプリケーションが既に503エラーを受信して途中で続行されているため、役に立たないことが問題です。
require 'sinatra'
require "json"
require 'sinatra/base'
require 'sinatra'
require 'json'
require 'fileutils'
require 'tempfile'
require "base64"
require 'puma_worker_killer'
PumaWorkerKiller.enable_rolling_restart
set :protection, except: [ :json_csrf ]
port = ENV['PORT'] || 8080
set :port, port
set :bind, '0.0.0.0'
post '/extractText' do
begin
bas64Image = Base64.decode64(params[:image])
imageFile = Tempfile.new(['image', '.png'])
imageFile.write(bas64Image)
imageFile.close
`textcleaner #{imageFile.path} #{imageFile.path}`
# `textdeskew #{imageFile.path} #{imageFile.path}`
output = `tesseract #{imageFile.path} --psm 6 --oem 2 stdout`
p output
rescue
status 402
return "Error reading image"
end
status 200
return output
end
HERESにHerokuのは、私が手を読み出す:
2017-10-23T20:22:00.548029+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/extractText" host=tesseractimageserver.herokuapp.com request_id=7b179829-ef1f-4e18-844b-42b90a5c5c69 fwd="82.32.79.208" dyno=web.1 connect=1ms service=30945ms status=503 bytes=0 protocol=https
2017-10-23T20:22:42.864098+00:00 app[web.1]: "Returned text from reading image using tesseract"
2017-10-23T20:22:42.872633+00:00 app[web.1]: 82.32.79.208 - - [23/Oct/2017:20:22:42 +0000] "POST /extractText HTTP/1.1" 200 467 72.2921
が同上これを回避する方法?