【发布时间】:2021-08-17 01:21:00
【问题描述】:
我在 Heroku 中使用 Ruby + Sinatra + puma + sequel 的应用程序是可以的,而工作进程 = 1 当增加工作进程 = 2 或如果增加 dyno = 2 我从系统中不同点随机丢失用户会话的问题开始使得通过heroku日志定位具体错误变得非常困难。
相同的应用程序适用于:
但是你失去了 session[:user] 的价值:
我的 app rack sinatra 类:
class Main <Sinatra :: Aplicación
use Rack :: Session :: Pool
set: protection ,: except =>: frame_options
def usuarioLogueado?
if defined?( session[:usuario] )
if session[:usuario].nil?
return false
else
return true
end
else
return false
end
end
get "/" do
if usuarioLogueado?
redirect "/app"
.....
else
redirect "/home"
end
end
end
我的续集:
pool_size = 10
@ db = Sequel.connect (strConexion ,: max_connections => pool_size )
@ db.extension (: connection_validator)
@ db.pool.connection_validation_timeout = -1
我的 puma.rb:(最多 20 个连接 DB)
workers Integer (ENV ['WEB_CONCURRENCY'] || 1)
threads_count = Integer (ENV ['MAX_THREADS'] || 10)
threads threads_count, threads_count
preload_app!
rackup DefaultRackup
port ENV ['PORT'] || 3000
【问题讨论】:
标签: ruby heroku sinatra puma sequel