Skip to content

Commit 468a400

Browse files
hakalbclaude
andcommitted
fix(web): health endpoint and remove deploy maintenance mode
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent d902941 commit 468a400

4 files changed

Lines changed: 5 additions & 72 deletions

File tree

apps/web/fly.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ primary_region = 'arn'
1414

1515
[[http_service.checks]]
1616
method = 'GET'
17-
path = '/'
17+
path = '/api/health'
1818
grace_period = '10s'
19-
interval = '20s'
19+
interval = '30s'
2020
timeout = '5s'
2121

2222
[[vm]]

apps/web/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const build = (await import(
2424
)) as unknown as RemixMiddlewareOptions['build'];
2525

2626
const app = new Hono()
27+
// Lightweight health check — must not trigger Remix/Payload data fetching
28+
.get('/api/health', (c) => c.text('ok'))
2729
// Serve static files from Remix client build
2830
.use('*', serveStatic({ root: './build/client' }))
2931
// Let Remix handle all requests

packages/fly-deployment-action/src/lib/utils/run-deploy-apps.ts

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,6 @@ export const runDeployApps = async (options: {
148148

149149
core.info(`Deploy app '${appName}' to '${environment}'${tenantLabel}...`);
150150

151-
// Enable maintenance mode on existing apps before deploying
152-
const appExists = (await fly.status({ app: appName })) !== null;
153-
if (appExists) {
154-
core.info(`Enabling maintenance mode for '${appName}'`);
155-
await fly.secrets.set({ MAINTENANCE_MODE: 'true' }, { app: appName });
156-
}
157-
158151
// Deploy app
159152
try {
160153
const result = await fly.deploy({
@@ -192,66 +185,6 @@ export const runDeployApps = async (options: {
192185
if (isHostDeployment) {
193186
failedHostApps.add(configAppName);
194187
}
195-
} finally {
196-
if (appExists) {
197-
core.info(`Disabling maintenance mode for '${appName}'`);
198-
// Fly.io machines may still be stabilizing after deploy — retry if the unset
199-
// fails with a concurrent-update error.
200-
let unsetSucceeded = false;
201-
const maxAttempts = 5;
202-
const retryDelayMs = 15_000;
203-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
204-
try {
205-
await fly.secrets.unset('MAINTENANCE_MODE', { app: appName });
206-
unsetSucceeded = true;
207-
break;
208-
} catch (cleanupError) {
209-
const msg =
210-
cleanupError instanceof Error
211-
? cleanupError.message
212-
: String(cleanupError);
213-
if (attempt === maxAttempts) {
214-
core.warning(
215-
`Failed to disable maintenance mode for '${appName}' after ${maxAttempts} attempts: ${msg}`
216-
);
217-
} else {
218-
core.info(
219-
`Retry ${attempt}/${maxAttempts - 1} disabling maintenance mode for '${appName}' in ${retryDelayMs / 1000}s: ${msg}`
220-
);
221-
await new Promise((r) => setTimeout(r, retryDelayMs));
222-
}
223-
}
224-
}
225-
226-
// MAINTENANCE_MODE is baked into the machine's per-machine config.env
227-
// from when it was a Fly secret during deployment. fly secrets unset
228-
// removes it from the secrets store but NOT from the machine-level config.
229-
// fly machine update creates a new machine version with the env var cleared,
230-
// forcing a cold restart — not a resume from a suspended memory snapshot.
231-
if (unsetSucceeded) {
232-
const statusAfterUnset = await fly.status({ app: appName });
233-
if (statusAfterUnset?.machines) {
234-
for (const machine of statusAfterUnset.machines) {
235-
try {
236-
core.info(
237-
`Clearing MAINTENANCE_MODE env for machine '${machine.id}' of '${appName}'`
238-
);
239-
await fly.machines.update(appName, machine.id, {
240-
env: { MAINTENANCE_MODE: '' }
241-
});
242-
} catch (updateErr) {
243-
const msg =
244-
updateErr instanceof Error
245-
? updateErr.message
246-
: String(updateErr);
247-
core.warning(
248-
`Failed to clear MAINTENANCE_MODE for machine '${machine.id}' of '${appName}': ${msg}`
249-
);
250-
}
251-
}
252-
}
253-
}
254-
}
255188
}
256189
}
257190

packages/fly-node/src/lib/fly.class.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,7 @@ export class Fly {
482482
try {
483483
await this.ensureInitialized();
484484
await this.updateMachine(app, machineId, options);
485-
this.logger.info(
486-
`Machine '${machineId}' in app '${app}' was updated`
487-
);
485+
this.logger.info(`Machine '${machineId}' in app '${app}' was updated`);
488486
} catch (error) {
489487
throw new Error(`[update machine] something broke\n${error}`);
490488
}

0 commit comments

Comments
 (0)