Add pre and post app boot hooks
Add two new hooks pre-app-boot and post-app-boot. They are analagous to the pre/post proxy reboot hooks. If the boot strategy deploys in groups, then the hooks are called once per group of hosts and `KAMAL_HOSTS` contains a comma delimited list of the hosts in that group. If all hosts are deployed to at once, then they are called once with `KAMAL_HOSTS` containing all the hosts. It is possible to have pauses between groups of hosts in the boot config, where this is the case the pause happens after the post-app-boot hook is called.
This commit is contained in:
@@ -15,7 +15,9 @@ class AppTest < IntegrationTest
|
||||
# kamal app start does not wait
|
||||
wait_for_app_to_be_up
|
||||
|
||||
kamal :app, :boot
|
||||
output = kamal :app, :boot, "--verbose", capture: true
|
||||
assert_match "Booting app on vm1,vm2...", output
|
||||
assert_match "Booted app on vm1,vm2...", output
|
||||
|
||||
wait_for_app_to_be_up
|
||||
|
||||
|
||||
3
test/integration/docker/deployer/app/.kamal/hooks/post-app-boot
Executable file
3
test/integration/docker/deployer/app/.kamal/hooks/post-app-boot
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
echo "Booted app on ${KAMAL_HOSTS}..."
|
||||
mkdir -p /tmp/${TEST_ID} && touch /tmp/${TEST_ID}/post-app-boot
|
||||
3
test/integration/docker/deployer/app/.kamal/hooks/pre-app-boot
Executable file
3
test/integration/docker/deployer/app/.kamal/hooks/pre-app-boot
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
echo "Booting app on ${KAMAL_HOSTS}..."
|
||||
mkdir -p /tmp/${TEST_ID} && touch /tmp/${TEST_ID}/pre-app-boot
|
||||
@@ -8,19 +8,19 @@ class MainTest < IntegrationTest
|
||||
|
||||
kamal :deploy
|
||||
assert_app_is_up version: first_version
|
||||
assert_hooks_ran "pre-connect", "pre-build", "pre-deploy", "post-deploy"
|
||||
assert_hooks_ran "pre-connect", "pre-build", "pre-deploy", "pre-app-boot", "post-app-boot", "post-deploy"
|
||||
assert_envs version: first_version
|
||||
|
||||
second_version = update_app_rev
|
||||
|
||||
kamal :redeploy
|
||||
assert_app_is_up version: second_version
|
||||
assert_hooks_ran "pre-connect", "pre-build", "pre-deploy", "post-deploy"
|
||||
assert_hooks_ran "pre-connect", "pre-build", "pre-deploy", "pre-app-boot", "post-app-boot", "post-deploy"
|
||||
|
||||
assert_accumulated_assets first_version, second_version
|
||||
|
||||
kamal :rollback, first_version
|
||||
assert_hooks_ran "pre-connect", "pre-deploy", "post-deploy"
|
||||
assert_hooks_ran "pre-connect", "pre-deploy", "pre-app-boot", "post-app-boot", "post-deploy"
|
||||
assert_app_is_up version: first_version
|
||||
|
||||
details = kamal :details, capture: true
|
||||
|
||||
Reference in New Issue
Block a user