Skip to content

Deployment strategy #49

@hut8

Description

@hut8

Ideally deployments should work like this:

  • Somehow get a binary in the right directory on the server (/home/ghc/ghc-app/bin/)
  • It should be named ghc-app-<sha1> where the sha1 is the first few hex-encoded bytes
  • Binding should always be done with SO_REUSEADDR
  • Side idea: bind each build to its own port that is derived from the SHA1 of the binary (Python 3):
app_bytes = open(r'path/to/ghc-app', 'rb').read()
app_hash = hashlib.sha1(app_bytes).digest()
port = int.from_bytes(app_hash, 'big') % (65535 - 1024)
  • Start the binary as a child process of the deployment thing listening on a test port on localhost (9001 maybe, since it's over 9000)
  • Run some basic tests on that to make sure it returns /stats for example
  • Kill the test process
  • Switch the link to ghc-app to the new build
  • Make a note of the old ghc-app's PID
  • Start the new ghc-app just like the old one, again using SO_REUSEADDR. So then two processes listen on the same port.
  • Kill old ghc-app

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions