Commit e3371ce
Keep the same ports across a restart
Summary:
The sandbox took a fresh ephemeral port on every restart, so anything already
pointed at it had to be repointed. `tao_sandbox_cli start` now binds a fixed
block -- `mock_tao` 18400/18401, `mock_ucache` 18402/18403 -- and refuses to
start if any of it is taken rather than quietly moving to a free port. Why that
block, and the reserved ranges it steers around, is in `SandboxPorts.h`.
Only `/tmp/tao_sandbox` claims the block. The flock is per output directory, so
a `--mock` instance or a test fixture on its own directory would otherwise
fight over it; those keep the ephemeral ports they take today. That is also how
tests isolate: a custom output directory, not a port override. `--random-ports`
is the single escape hatch, restoring the old behaviour wholesale.
`SO_REUSEADDR` is set on the fixed sockets so `TIME_WAIT` from the previous
instance does not block a rebind, while a live listener still fails. Without it
every restart inside the `TIME_WAIT` window would fail to start.
`tao_sandbox_cli start` now bails on a non-zero daemon exit with the tail of
`tao_sandbox.err`; without it a port conflict spins for the full 300s timeout.
Out of scope: `mock_ucache`'s thrift listener, `mock_prod`, and toaster mode's
MySQL/gateway/writer/ucache/wormhole instances stay ephemeral.
Reviewed By: ghostonhuang
Differential Revision: D118218228
fbshipit-source-id: cde007cd942ee45bc66f78349916a0c43839bb581 parent 8f073d4 commit e3371ce
2 files changed
Lines changed: 48 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
53 | 54 | | |
54 | 55 | | |
55 | 56 | | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
56 | 65 | | |
57 | 66 | | |
58 | 67 | | |
| |||
78 | 87 | | |
79 | 88 | | |
80 | 89 | | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
86 | 97 | | |
87 | 98 | | |
88 | | - | |
89 | | - | |
| 99 | + | |
| 100 | + | |
90 | 101 | | |
91 | 102 | | |
92 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
93 | 117 | | |
94 | 118 | | |
95 | 119 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
26 | 38 | | |
27 | 39 | | |
28 | 40 | | |
| |||
61 | 73 | | |
62 | 74 | | |
63 | 75 | | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
64 | 79 | | |
65 | 80 | | |
66 | 81 | | |
| |||
0 commit comments