@replayio/app-building 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fly.js +12 -3
- package/package.json +1 -1
package/dist/fly.js
CHANGED
|
@@ -83,7 +83,8 @@ export async function deleteVolume(app, token, volumeId) {
|
|
|
83
83
|
*/
|
|
84
84
|
export async function createMachine(app, token, image, env, name) {
|
|
85
85
|
// Create a volume for /repo storage
|
|
86
|
-
const
|
|
86
|
+
const volumeName = `repo_${name.replace(/-/g, "_")}`.slice(0, 30);
|
|
87
|
+
const volumeId = await createVolume(app, token, volumeName, 50);
|
|
87
88
|
try {
|
|
88
89
|
const res = await flyFetch(`/apps/${app}/machines`, token, {
|
|
89
90
|
method: "POST",
|
|
@@ -126,14 +127,22 @@ export async function createMachine(app, token, image, env, name) {
|
|
|
126
127
|
*/
|
|
127
128
|
export async function waitForMachine(app, token, machineId, timeoutMs = 180000) {
|
|
128
129
|
const start = Date.now();
|
|
130
|
+
let lastLogTime = 0;
|
|
129
131
|
while (Date.now() - start < timeoutMs) {
|
|
130
132
|
try {
|
|
131
133
|
await flyFetch(`/apps/${app}/machines/${machineId}/wait?state=started&timeout=60`, token);
|
|
132
134
|
return;
|
|
133
135
|
}
|
|
134
136
|
catch (e) {
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
+
const now = Date.now();
|
|
138
|
+
const elapsed = Math.round((now - start) / 1000);
|
|
139
|
+
// Only log at most once every 10 seconds
|
|
140
|
+
if (now - lastLogTime >= 10000) {
|
|
141
|
+
console.log(`Still waiting for machine to start (${elapsed}s elapsed): ${e instanceof Error ? e.message : e}`);
|
|
142
|
+
lastLogTime = now;
|
|
143
|
+
}
|
|
144
|
+
// Wait before retrying
|
|
145
|
+
await new Promise((r) => setTimeout(r, 5000));
|
|
137
146
|
}
|
|
138
147
|
}
|
|
139
148
|
throw new Error(`Machine ${machineId} did not reach started state within ${timeoutMs / 1000}s`);
|