teletraan icon indicating copy to clipboard operation
teletraan copied to clipboard

Feature request: ability to stop/start environments

Open nathantypanski opened this issue 7 years ago • 5 comments

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:

  1. Go to the environment -> all hosts page.
  2. Terminate the desired hosts.
  3. Do whatever workflow tasks are required while the hosts are down.
  4. Go to the environment -> all hosts page.
  5. 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.

nathantypanski avatar Mar 14 '17 00:03 nathantypanski

Have you tried the restart button on the environment page? It should restart services on all hosts

lilida avatar Mar 14 '17 02:03 lilida

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?

nathantypanski avatar Mar 14 '17 20:03 nathantypanski

I see. So the real ask here is a STOP script support as existing PRE_RESTART or RESTART?

lilida avatar Mar 15 '17 03:03 lilida

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.

nathantypanski avatar Mar 15 '17 18:03 nathantypanski

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 ...

nathantypanski avatar Mar 16 '17 01:03 nathantypanski