-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
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
/statsfor example - Kill the test process
- Switch the link to
ghc-appto the new build - Make a note of the old
ghc-app's PID - Start the new
ghc-appjust like the old one, again usingSO_REUSEADDR. So then two processes listen on the same port. - Kill old
ghc-app