Skip to content

Commit

Permalink
webserver: enable crowbar to change workers/threads itself
Browse files Browse the repository at this point in the history
  • Loading branch information
MaximilianMeister committed Nov 23, 2016
1 parent 4232291 commit 4aabda9
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 6 deletions.
6 changes: 6 additions & 0 deletions chef/cookbooks/crowbar/recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,8 @@
unless node["crowbar"].nil? or node["crowbar"]["users"].nil? or node["crowbar"]["realm"].nil?
web_port = node["crowbar"]["web_port"] || 3000
realm = node["crowbar"]["realm"]
workers = node["crowbar"]["workers"] || 2
threads = node["crowbar"]["threads"] || 16

users = {}
node["crowbar"]["users"].each do |k,h|
Expand All @@ -252,6 +254,8 @@
else
web_port = 3000
realm = nil
workers = 2
threads = 16
end

# Remove rainbows configuration, dating from before the switch to puma
Expand All @@ -267,6 +271,8 @@
variables(
web_host: "127.0.0.1",
web_port: web_port,
workers: workers,
threads: threads
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CROWBAR_ENV="production"
## Default: 16
## ServiceRestart: crowbar
# Sets the maximum number of threads used by the web server.
CROWBAR_THREADS="16"
CROWBAR_THREADS="<%= @threads %>"

## Path: Crowbar
## Description: Maximum number of worker processes
Expand All @@ -23,7 +23,7 @@ CROWBAR_THREADS="16"
## ServiceRestart: crowbar
# Sets the maximum number of separate worker processes spawned by the
# web server.
CROWBAR_WORKERS="2"
CROWBAR_WORKERS="<%= @workers %>"

## Path: Crowbar
## Description: Listen address
Expand All @@ -40,4 +40,3 @@ CROWBAR_LISTEN="<%= @web_host %>"
## ServiceRestart: crowbar
# Port which Crowbar listens to.
CROWBAR_PORT=<%= @web_port %>

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def upgrade(ta, td, a, d)
a["workers"] = ta["workers"]
a["threads"] = ta["threads"]
return a, d
end

def downgrade(ta, td, a, d)
a.delete("workers")
a.delete("threads")
return a, d
end
4 changes: 3 additions & 1 deletion chef/data_bags/crowbar/template-crowbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
},
"realm": "Crowbar - By selecting OK you are agreeing to the License Agreement",
"web_port": 3000,
"workers": 2,
"threads": 16,
"users": {
"machine-install": { "password": "machine_password" },
"crowbar": { "password": "crowbar" }
Expand All @@ -28,7 +30,7 @@
"crowbar": {
"crowbar-revision": 0,
"crowbar-applied": false,
"schema-revision": 100,
"schema-revision": 101,
"element_states": {
"crowbar": [ "all" ],
"crowbar-upgrade": [ "readying", "ready", "applying", "crowbar_upgrade" ]
Expand Down
4 changes: 3 additions & 1 deletion chef/data_bags/crowbar/template-crowbar.schema
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
}
},
"web_port": { "type": "int", "required": true },
"workers": { "type": "int", "required": true },
"threads": { "type": "int", "required": true },
"realm": { "type": "str", "required": false },
"users": { "type": "map", "required": true, "mapping": {
= : { "type": "map", "required": true, "mapping": {
= : { "type": "map", "required": true, "mapping": {
"password": { "type": "str" },
"digest": { "type": "str" },
"disabled": { "type": "bool" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
},
"realm": "Crowbar - By selecting OK you are agreeing to the License Agreement",
"web_port": 3000,
"workers": 2,
"threads": 16,
"users": {
"machine-install": { "password": "machine_password" },
"crowbar": { "password": "crowbar" }
Expand Down Expand Up @@ -46,4 +48,3 @@
}
}
}

0 comments on commit 4aabda9

Please sign in to comment.