Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployment strategy #49

Open
hut8 opened this issue Jan 30, 2016 · 0 comments
Open

Deployment strategy #49

hut8 opened this issue Jan 30, 2016 · 0 comments

Comments

@hut8
Copy link
Member

hut8 commented Jan 30, 2016

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant