teletraan
teletraan copied to clipboard
Feature request: ability to stop/start environments
I'm evaluating Teletraan as a replacement for Capistrano. One important feature in our Capistrano deployment system is the ability to run our init scripts to stop/start all hosts in what Teletraan calls an "environment".
It looks like I can roughly emulate this with the following workflow, when hosts are enumerated explicitly in the "Capacity" page:
- Go to the environment -> all hosts page.
- Terminate the desired hosts.
- Do whatever workflow tasks are required while the hosts are down.
- Go to the environment -> all hosts page.
- Perform the RESET action on the previously stopped hosts.
This is pretty clunky, however: it downloads a new build and goes through the complete lifecycle for a host (from PRE_DOWNLOAD
to POST_RESTART
). Really, all we need to run is RESTARTING
and POST_RESTART
to resume a host from the STOPPED
state. It would be nice if there were a way to do this directly.
Have you tried the restart button on the environment page? It should restart services on all hosts
Yes, I've tried the restart button - that does not allow me to take an environment offline for a controlled period of time, which is the main thing I'm trying to do here. e.g., bring down an environment while I run migrations. Does that make sense?
I see. So the real ask here is a STOP script support as existing PRE_RESTART or RESTART?
Sure. Akin to clicking the RESTART
button, you click a STOP
button that runs a STOP
script. Then, maybe reusing the RESUME
button starts the environment again.
One thing I noticed: the service will actually try to use STOPPING
and STOPPED
scripts for these states already when they are encountered. In my deploy-agent.log
, I noticed:
INFO:deployd.common.executor:script: /tmp/simplehttpserver/teletraan/STOPPING does not exist.
To test this out, I created a STOPPING
script, and sure enough, it worked! But it doesn't perform interpolation of environment variables like the normal script execution stages. Output from my application's log shows the following, even though I have PORT
set to 8000
in my Script Config:
Running STOPPING script.
PORT:
ENV_NAME simplehttpserver
STAGE_NAME canary
DEPLOY_ID M-hE1FdZQVug0BvrwyFroQ
DEPLOY_STE STOPPING
OPCODE STOP
DEPLOY_TYP STOP
BUILD_COMM a2f66f12f8cc3c416bf5ee0bffe808d57b5c1fc0
BUILD_NAME target
BUILD_REPO snip
BUILD_BRAN master
BUILD_ID tmEbxK40QK6JQm_DzEBdbQ_a2f66f1
BUILD_URL snip
For some extra context: I'm trying to use the STOPPING state to gracefully shutdown my application so I can do long-running tasks like perform database migrations for an application while its frontend environment is down.
If this isn't the intended use of the Terminate button, then I suppose I will have to find another way to do it ...