Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit bc415aa

Browse files
committed
chore(core): auto-start engine in development for serverless runners & disable health check in serverless (#1411)
1 parent 4aa6549 commit bc415aa

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

examples/counter-serverless/src/server.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ import { registry } from "./registry";
33
registry.start({
44
runnerKind: "serverless",
55
autoConfigureServerless: { url: "http://localhost:8080" },
6-
endpoint: "http://localhost:6420",
76
});

packages/next-js/src/mod.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export const toNextHandler = (
1111
// Configure serverless
1212
inputConfig.runnerKind = "serverless";
1313

14-
// TODO: We probably want to move this to the registry for all serverless runners
15-
// Metadata endpoint will not exist at 127.0.0.1:6420
16-
inputConfig.disableHealthCheck = true;
17-
1814
// Auto-configure serverless runner if not in prod
1915
if (process.env.NODE_ENV !== "production") {
2016
logger().debug(

packages/rivetkit/src/registry/mod.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,25 @@ export class Registry<A extends RegistryActors> {
7171
// Promise for any async operations we need to wait to complete
7272
const readyPromises = [];
7373

74+
// Disable health check if using serverless
75+
//
76+
// This is because the endpoint will not be configured until we receive
77+
// a serverless runner request, so we do not know what to health check
78+
if (config.runnerKind === "serverless") {
79+
logger().debug("disabling health check since using serverless");
80+
config.disableHealthCheck = true;
81+
}
82+
83+
// Auto-configure serverless runner if not in prod
84+
if (
85+
process.env.NODE_ENV !== "production" &&
86+
config.runnerKind === "serverless"
87+
) {
88+
if (inputConfig?.runEngine === undefined) config.runEngine = true;
89+
if (inputConfig?.autoConfigureServerless === undefined)
90+
config.autoConfigureServerless = true;
91+
}
92+
7493
// Start engine
7594
if (config.runEngine) {
7695
logger().debug({
@@ -185,6 +204,7 @@ export class Registry<A extends RegistryActors> {
185204
// Even though we do not use the returned ActorDriver, this is required to start the code that will handle incoming actors
186205
if (!config.disableActorDriver) {
187206
Promise.all(readyPromises).then(async () => {
207+
logger().debug("starting actor driver");
188208
driver.actor(this.#config, config, managerDriver, client);
189209
});
190210
}
@@ -220,6 +240,8 @@ export class Registry<A extends RegistryActors> {
220240
}
221241

222242
async function configureServerlessRunner(config: RunnerConfig): Promise<void> {
243+
logger().debug("configuring serverless runner");
244+
223245
try {
224246
// Ensure we have required config values
225247
if (!config.runnerName) {
@@ -290,10 +312,11 @@ async function configureServerlessRunner(config: RunnerConfig): Promise<void> {
290312
});
291313
} catch (error) {
292314
logger().error({
293-
msg: "failed to configure serverless runner",
315+
msg: "failed to configure serverless runner, validate endpoint is configured correctly then restart this process",
294316
error,
295317
});
296-
throw error;
318+
319+
// Don't throw, allow the runner to continue
297320
}
298321
}
299322

packages/rivetkit/src/remote-manager-driver/mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class RemoteManagerDriver implements ManagerDriver {
109109
});
110110
} catch (error) {
111111
logger().error({
112-
msg: "failed to connect to metadata endpoint",
112+
msg: "health check failed, validate the Rivet endpoint is configured correctly",
113113
endpoint,
114114
error: stringifyError(error),
115115
});

0 commit comments

Comments
 (0)