Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to configure the number of web workers for puma #124

Merged
merged 3 commits into from
Jan 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add support to configure the number of web workers for puma
  • Loading branch information
Zach Hall committed Jan 27, 2023
commit 086a1cba669b9d6f0b7648d0d259ac4643d4cda3
11 changes: 10 additions & 1 deletion lib/kuby/docker/webserver_phase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class Puma < Webserver
def apply_to(dockerfile)
dockerfile.cmd(
'puma',
'--workers', '4',
'--workers', phase.workers.to_s,
'--bind', 'tcp://0.0.0.0',
'--port', phase.port.to_s,
'--pidfile', './server.pid',
Expand All @@ -40,11 +40,15 @@ def apply_to(dockerfile)
end

DEFAULT_PORT = T.let(8080, Integer)
DEFAULT_WORKERS = T.let(4, Integer)
WEBSERVER_MAP = T.let({ puma: Puma }.freeze, T::Hash[Symbol, T.class_of(Webserver)])

T::Sig::WithoutRuntime.sig { params(port: Integer).returns(Integer) }
attr_writer :port

T::Sig::WithoutRuntime.sig { params(port: Integer).returns(Integer) }
attr_writer :workers

T::Sig::WithoutRuntime.sig { returns(T.nilable(Symbol)) }
attr_reader :webserver

Expand All @@ -56,6 +60,7 @@ def initialize(environment)
super

@port = T.let(@port, T.nilable(Integer))
@workers = T.let(@workers, T.nilable(Integer))
@webserver = T.let(@webserver, T.nilable(Symbol))
end

Expand All @@ -73,6 +78,10 @@ def port
@port || DEFAULT_PORT
end

def workers
@workers || DEFAULT_WORKERS
end

private

T::Sig::WithoutRuntime.sig { returns(T.nilable(Symbol)) }
Expand Down