Maintenance mode
Adds support for maintenance mode to Kamal. There are two new commands: - `kamal app maintenance` - puts the app in maintenance mode - `kamal app live` - puts the app back in live mode In maintenance mode, the kamal proxy will respond to requests with a 503 status code. It will use an error page built into kamal proxy. You can use your own error page by setting `error_pages_path` in the configuration. This will copy any 4xx.html or 5xx.html files from that page to a volume mounted into the proxy container.
This commit is contained in:
@@ -48,9 +48,36 @@ class AppTest < IntegrationTest
|
||||
assert_match "App Host: vm1", exec_output
|
||||
assert_match /1 root 0:\d\d nginx/, exec_output
|
||||
|
||||
kamal :app, :maintenance
|
||||
assert_app_in_maintenance
|
||||
|
||||
kamal :app, :live
|
||||
assert_app_is_up
|
||||
|
||||
kamal :app, :remove
|
||||
|
||||
assert_app_not_found
|
||||
assert_app_directory_removed
|
||||
end
|
||||
|
||||
test "custom error pages" do
|
||||
@app = "app_with_roles"
|
||||
|
||||
kamal :deploy
|
||||
assert_app_is_up
|
||||
|
||||
kamal :app, :maintenance
|
||||
assert_app_in_maintenance message: "Custom Maintenance Page"
|
||||
|
||||
kamal :app, :live
|
||||
kamal :app, :maintenance, "--message", "\"Testing Maintence Mode\""
|
||||
assert_app_in_maintenance message: "Custom Maintenance Page: Testing Maintence Mode"
|
||||
|
||||
second_version = update_app_rev
|
||||
|
||||
kamal :redeploy
|
||||
|
||||
kamal :app, :maintenance
|
||||
assert_app_in_maintenance message: "Custom Maintenance Page"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,6 +37,7 @@ proxy:
|
||||
- X-Request-Start
|
||||
|
||||
asset_path: /usr/share/nginx/html/versions
|
||||
error_pages_path: error_pages
|
||||
|
||||
registry:
|
||||
server: registry:4443
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>503 Service Interrupted</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Custom Maintenance Page: {{ .Message }}</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -45,15 +45,22 @@ class IntegrationTest < ActiveSupport::TestCase
|
||||
end
|
||||
|
||||
def assert_app_is_down
|
||||
response = app_response
|
||||
debug_response_code(response, "502")
|
||||
assert_equal "502", response.code
|
||||
assert_app_error_code("502")
|
||||
end
|
||||
|
||||
def assert_app_in_maintenance(message: nil)
|
||||
assert_app_error_code("503", message: message)
|
||||
end
|
||||
|
||||
def assert_app_not_found
|
||||
assert_app_error_code("404")
|
||||
end
|
||||
|
||||
def assert_app_error_code(code, message: nil)
|
||||
response = app_response
|
||||
debug_response_code(response, "404")
|
||||
assert_equal "404", response.code
|
||||
debug_response_code(response, code)
|
||||
assert_equal code, response.code
|
||||
assert_match message, response.body.strip if message
|
||||
end
|
||||
|
||||
def assert_app_is_up(version: nil, app: @app)
|
||||
|
||||
Reference in New Issue
Block a user