polen 0.11.0-next.27 → 0.11.0-next.28
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/build/api/builder/ssg/generate.d.ts.map +1 -1
- package/build/api/builder/ssg/generate.js +76 -50
- package/build/api/builder/ssg/generate.js.map +1 -1
- package/build/api/builder/ssg/page-generator.worker.js +59 -55
- package/build/api/builder/ssg/page-generator.worker.js.map +1 -1
- package/build/api/builder/ssg/server-runner.worker.js +34 -40
- package/build/api/builder/ssg/server-runner.worker.js.map +1 -1
- package/build/api/builder/ssg/worker-messages.d.ts +10 -0
- package/build/api/builder/ssg/worker-messages.d.ts.map +1 -1
- package/build/api/builder/ssg/worker-messages.js +7 -1
- package/build/api/builder/ssg/worker-messages.js.map +1 -1
- package/build/vite/plugins/routes-manifest.d.ts.map +1 -1
- package/build/vite/plugins/routes-manifest.js +5 -2
- package/build/vite/plugins/routes-manifest.js.map +1 -1
- package/package.json +38 -42
- package/src/api/builder/ssg/generate.ts +111 -71
- package/src/api/builder/ssg/page-generator.worker.ts +106 -74
- package/src/api/builder/ssg/server-runner.worker.ts +39 -44
- package/src/api/builder/ssg/worker-messages.ts +11 -1
- package/src/vite/plugins/routes-manifest.ts +5 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/api/builder/ssg/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../../src/api/builder/ssg/generate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAI3C,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,OAAO,EAA0B,MAAM,EAA8B,MAAM,QAAQ,CAAA;AAYnF,eAAO,MAAM,QAAQ,GAAI,QAAQ,MAAM,CAAC,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,UAAU,CAyPlF,CAAA"}
|
@@ -1,16 +1,14 @@
|
|
1
1
|
import { Routes } from '#api/routes/$';
|
2
|
-
import { debugPolen } from '#singletons/debug';
|
3
2
|
import { Worker } from '@effect/platform';
|
4
3
|
import { NodeContext, NodeWorker } from '@effect/platform-node';
|
5
4
|
import { FileSystem } from '@effect/platform/FileSystem';
|
6
5
|
import { Path } from '@wollybeard/kit';
|
7
6
|
import consola from 'consola';
|
8
|
-
import { Array, Chunk, Effect, Layer } from 'effect';
|
7
|
+
import { Array, Chunk, Duration, Effect, Either, Layer, Logger, Ref } from 'effect';
|
9
8
|
import getPort from 'get-port';
|
10
9
|
import { cpus, totalmem } from 'node:os';
|
11
10
|
import { GeneratePagesMessage, PageMessage, ServerMessage, StartServerMessage, } from './worker-messages.js';
|
12
11
|
import { createPageSpawner, createServerSpawner } from './worker-spawners.js';
|
13
|
-
const debug = debugPolen.sub(`api:ssg:generate`);
|
14
12
|
export const generate = (config) => Effect.gen(function* () {
|
15
13
|
// Read routes from the manifest generated during build
|
16
14
|
const manifest = yield* Routes.Manifest.get(config.paths.project.absolute.build.assets.root);
|
@@ -34,19 +32,19 @@ export const generate = (config) => Effect.gen(function* () {
|
|
34
32
|
consola.info(` Clients: ${optimalWorkers} page generators (to capture HTML)`);
|
35
33
|
consola.info(` Distribution: ${batches.length} batches × ~${batchSize} pages each`);
|
36
34
|
consola.info(` System: ${cpuCount} CPUs, ${memoryGB.toFixed(1)}GB RAM`);
|
37
|
-
|
35
|
+
yield* Effect.logDebug(`SSG configuration`).pipe(Effect.annotateLogs({
|
38
36
|
totalRoutes,
|
39
37
|
optimalWorkers,
|
40
38
|
cpuCount,
|
41
39
|
memoryGB,
|
42
40
|
batchSize,
|
43
41
|
totalBatches: batches.length,
|
44
|
-
});
|
42
|
+
}));
|
45
43
|
// Create worker spawner layers
|
46
44
|
const serverPath = config.paths.project.absolute.build.serverEntrypoint;
|
47
45
|
const serverRunnerPath = Path.join(config.paths.framework.sourceDir, 'api/builder/ssg/server-runner.worker' + config.paths.framework.sourceExtension);
|
48
46
|
const pageGeneratorPath = Path.join(config.paths.framework.sourceDir, 'api/builder/ssg/page-generator.worker' + config.paths.framework.sourceExtension);
|
49
|
-
|
47
|
+
yield* Effect.logDebug(`Creating worker pools with ${optimalWorkers} workers each`);
|
50
48
|
// Create and use worker pools within a scoped context
|
51
49
|
yield* Effect.scoped(Effect.gen(function* () {
|
52
50
|
// Create the server pool with its spawner
|
@@ -61,7 +59,7 @@ export const generate = (config) => Effect.gen(function* () {
|
|
61
59
|
const serverPorts = [];
|
62
60
|
consola.info(`\nStarting SSG infrastructure:`);
|
63
61
|
consola.info(` Launching ${optimalWorkers} Polen app instances...`);
|
64
|
-
|
62
|
+
yield* Effect.logDebug(`Finding available ports for servers`);
|
65
63
|
// Get available ports
|
66
64
|
for (let i = 0; i < optimalWorkers; i++) {
|
67
65
|
const port = yield* Effect.tryPromise({
|
@@ -70,19 +68,18 @@ export const generate = (config) => Effect.gen(function* () {
|
|
70
68
|
});
|
71
69
|
serverPorts.push(port);
|
72
70
|
}
|
73
|
-
|
71
|
+
yield* Effect.logDebug(`Using ports: ${serverPorts.join(', ')}`);
|
74
72
|
// Start servers using Effect
|
75
73
|
yield* Effect.all(serverPorts.map((port) => serverPool.executeEffect(new StartServerMessage({
|
76
74
|
serverPath,
|
77
75
|
port,
|
78
76
|
}))), { concurrency: 'unbounded' });
|
79
77
|
consola.success(` All ${optimalWorkers} app instances ready on ports: ${serverPorts.join(', ')}`);
|
80
|
-
|
78
|
+
yield* Effect.logDebug(`All servers started successfully`);
|
81
79
|
// Prepare page generation configs
|
82
80
|
// Each batch is assigned to a server in round-robin fashion
|
83
81
|
const generateConfigs = batches.map((batch, index) => {
|
84
82
|
const assignedPort = serverPorts[index % serverPorts.length];
|
85
|
-
debug(`Batch ${index + 1}: ${batch.length} routes → server on port ${assignedPort}`);
|
86
83
|
return {
|
87
84
|
batch,
|
88
85
|
assignedPort,
|
@@ -94,56 +91,85 @@ export const generate = (config) => Effect.gen(function* () {
|
|
94
91
|
consola.info(` Routes are distributed round-robin across ${optimalWorkers} servers`);
|
95
92
|
// Process batches
|
96
93
|
consola.info(`\nGenerating pages...`);
|
97
|
-
const
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
const results = yield* Effect.forEach(generateConfigs, ({ batch, assignedPort, index }) => pagePool
|
94
|
+
const completedBatchesRef = yield* Ref.make(0);
|
95
|
+
const totalPagesProcessedRef = yield* Ref.make(0);
|
96
|
+
// Process batches using Effect.all with timing
|
97
|
+
const [elapsedTime, results] = yield* Effect.all(generateConfigs.map(({ batch, assignedPort, index }) => pagePool
|
102
98
|
.executeEffect(new GeneratePagesMessage({
|
103
99
|
routes: batch,
|
104
100
|
serverPort: assignedPort,
|
105
101
|
outputDir: config.paths.project.absolute.build.root,
|
106
102
|
}))
|
107
|
-
.pipe(Effect.tap((result) => Effect.
|
108
|
-
completedBatches
|
109
|
-
totalPagesProcessed
|
110
|
-
|
111
|
-
const pagesPerSec = elapsed > 0 ? (totalPagesProcessed / elapsed).toFixed(1) : '0';
|
103
|
+
.pipe(Effect.tap((result) => Effect.gen(function* () {
|
104
|
+
const completedBatches = yield* Ref.updateAndGet(completedBatchesRef, n => n + 1);
|
105
|
+
const totalPagesProcessed = yield* Ref.updateAndGet(totalPagesProcessedRef, n => n + result.processedCount);
|
106
|
+
// Still use process.stdout.write for progress bar - this is UI, not logging
|
112
107
|
const progress = Math.floor((completedBatches / batches.length) * 100);
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
108
|
+
yield* Effect.sync(() => {
|
109
|
+
process.stdout.write(`\r Progress: ${completedBatches}/${batches.length} batches (${progress}%) • ${totalPagesProcessed}/${totalRoutes} pages`);
|
110
|
+
});
|
111
|
+
})), Effect.tapError((error) => Effect.logError(`Batch ${index} failed`).pipe(Effect.annotateLogs({ error: String(error), batch }))), Effect.map((result) => ({ ...result, batchIndex: index })), Effect.either)), { concurrency: optimalWorkers }).pipe(Effect.timed);
|
112
|
+
// Partition results into successes and failures
|
113
|
+
const [lefts, rights] = Array.partition(results, Either.isRight);
|
114
|
+
const successfulResults = rights.map(r => r.right);
|
115
|
+
const failedBatches = lefts.map(r => ({
|
116
|
+
error: r.left instanceof Error ? r.left.message : String(r.left),
|
117
|
+
}));
|
123
118
|
// Final stats using successful results
|
124
|
-
const totalTime = (
|
125
|
-
const
|
126
|
-
const
|
127
|
-
|
128
|
-
/
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
119
|
+
const totalTime = (Duration.toMillis(elapsedTime) / 1000).toFixed(1);
|
120
|
+
const actualPagesGenerated = yield* Ref.get(totalPagesProcessedRef);
|
121
|
+
const totalFailures = totalRoutes - actualPagesGenerated;
|
122
|
+
if (successfulResults.length > 0) {
|
123
|
+
const totalMemoryMB = Array.reduce(successfulResults, 0, (sum, r) => sum + r.memoryUsed) / (1024 * 1024);
|
124
|
+
const avgTimePerBatch = Array.reduce(successfulResults, 0, (sum, r) => sum + r.duration)
|
125
|
+
/ successfulResults.length
|
126
|
+
/ 1000;
|
127
|
+
if (totalFailures === 0) {
|
128
|
+
consola.success(`\n\nSSG Complete!`);
|
129
|
+
consola.info(` Generated: ${actualPagesGenerated} pages in ${totalTime}s`);
|
130
|
+
consola.info(` Performance: ${(actualPagesGenerated / parseFloat(totalTime)).toFixed(1)} pages/sec`);
|
131
|
+
consola.info(` Avg batch time: ${avgTimePerBatch.toFixed(1)}s`);
|
132
|
+
consola.info(` Peak memory: ${totalMemoryMB.toFixed(0)}MB`);
|
133
|
+
}
|
134
|
+
else {
|
135
|
+
consola.warn(`\n\nSSG Completed with Errors`);
|
136
|
+
consola.info(` Generated: ${actualPagesGenerated} out of ${totalRoutes} pages`);
|
137
|
+
consola.error(` Failed: ${totalFailures} pages`);
|
138
|
+
consola.info(` Time: ${totalTime}s`);
|
139
|
+
consola.info(` Performance: ${(actualPagesGenerated / parseFloat(totalTime)).toFixed(1)} pages/sec`);
|
140
|
+
consola.info(` Avg batch time: ${avgTimePerBatch.toFixed(1)}s`);
|
141
|
+
consola.info(` Peak memory: ${totalMemoryMB.toFixed(0)}MB`);
|
142
|
+
// Log details of failures from each batch
|
143
|
+
const allFailures = successfulResults.flatMap(r => r.failures ?? []);
|
144
|
+
if (allFailures.length > 0) {
|
145
|
+
consola.error(`\n Failed routes:`);
|
146
|
+
for (const failure of allFailures.slice(0, 10)) {
|
147
|
+
consola.error(` - ${failure.route}: ${failure.error}`);
|
148
|
+
}
|
149
|
+
if (allFailures.length > 10) {
|
150
|
+
consola.error(` ... and ${allFailures.length - 10} more`);
|
151
|
+
}
|
152
|
+
}
|
153
|
+
// Fail the effect to indicate error
|
154
|
+
yield* Effect.fail(new Error(`SSG failed: ${totalFailures} pages could not be generated`));
|
155
|
+
}
|
156
|
+
}
|
157
|
+
else {
|
158
|
+
consola.error(`\n\nSSG Failed Completely`);
|
159
|
+
consola.error(` No pages were generated out of ${totalRoutes} total`);
|
160
|
+
yield* Effect.fail(new Error(`SSG failed: No pages could be generated`));
|
161
|
+
}
|
162
|
+
yield* Effect.logDebug(`SSG generation complete`).pipe(Effect.annotateLogs({
|
135
163
|
totalTime,
|
136
|
-
avgTimePerBatch,
|
137
|
-
totalMemoryMB,
|
138
164
|
successfulBatches: successfulResults.length,
|
139
|
-
});
|
140
|
-
// Cleanup happens automatically when the scope ends
|
141
|
-
debug(`SSG generation complete, cleaning up resources`);
|
165
|
+
}));
|
142
166
|
}).pipe(
|
143
167
|
// Provide NodeContext for Path service used in page generator
|
144
|
-
Effect.provide(NodeContext.layer)))
|
145
|
-
|
146
|
-
|
147
|
-
|
168
|
+
Effect.provide(NodeContext.layer))).pipe(
|
169
|
+
// After scoped resources are released
|
170
|
+
Effect.tap(() => Effect.sync(() => {
|
171
|
+
consola.info('\nShutting down...');
|
172
|
+
consola.success('Cleanup complete.');
|
173
|
+
})), Effect.tap(() => Effect.logDebug(`All resources cleaned up`)));
|
148
174
|
});
|
149
175
|
//# sourceMappingURL=generate.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/api/builder/ssg/generate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../../../src/api/builder/ssg/generate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AACnF,OAAO,OAAO,MAAM,UAAU,CAAA;AAC9B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EACL,oBAAoB,EAEpB,WAAW,EACX,aAAa,EACb,kBAAkB,GACnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AAE7E,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,MAAqB,EAA0C,EAAE,CACxF,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,uDAAuD;IACvD,MAAM,QAAQ,GAAG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,KAAK,CAAC,yCAAyC,CAAC,CAAC,CAAA;QAC1E,CAAC;QAED,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,yBAAyB,CAAC,CAAC,IAAI,CACpD,MAAM,CAAC,YAAY,CAAC;YAClB,SAAS;YACT,iBAAiB,EAAE,iBAAiB,CAAC,MAAM;SAC5C,CAAC,CACH,CAAA;IACH,CAAC,CAAC,CAAC,IAAI;IACL,8DAA8D;IAC9D,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAClC,CACF,CAAC,IAAI;IACJ,sCAAsC;IACtC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CACd,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;QACf,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QAClC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACtC,CAAC,CAAC,CACH,EACD,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,0BAA0B,CAAC,CAAC,CAC9D,CAAA;AACH,CAAC,CAAC,CAAA"}
|
@@ -2,13 +2,10 @@
|
|
2
2
|
* Worker that generates static pages by fetching from servers.
|
3
3
|
* This is executed in a worker thread using Effect Worker API.
|
4
4
|
*/
|
5
|
-
import {
|
6
|
-
import { Path, WorkerRunner } from '@effect/platform';
|
5
|
+
import { FileSystem, Path, WorkerRunner } from '@effect/platform';
|
7
6
|
import { NodeContext, NodeRuntime, NodeWorkerRunner } from '@effect/platform-node';
|
8
|
-
import { Data, Effect, Layer } from 'effect';
|
9
|
-
import { promises as fs } from 'node:fs';
|
7
|
+
import { Array, Data, Duration, Effect, Either, Layer } from 'effect';
|
10
8
|
import { PageMessage } from './worker-messages.js';
|
11
|
-
const debug = debugPolen.sub(`api:ssg:page-generator`);
|
12
9
|
// ============================================================================
|
13
10
|
// Error Types
|
14
11
|
// ============================================================================
|
@@ -23,68 +20,75 @@ class RouteProcessingError extends Data.Error {
|
|
23
20
|
// ============================================================================
|
24
21
|
// Generate Pages Handler
|
25
22
|
// ============================================================================
|
23
|
+
// Fetch HTML from server using Effect patterns
|
24
|
+
const fetchPage = (url) => Effect.gen(function* () {
|
25
|
+
const response = yield* Effect.tryPromise({
|
26
|
+
try: () => fetch(url),
|
27
|
+
catch: (error) => new Error(`Network error: ${error}`),
|
28
|
+
});
|
29
|
+
if (!response.ok) {
|
30
|
+
return yield* Effect.fail(new Error(`HTTP ${response.status}: ${response.statusText}`));
|
31
|
+
}
|
32
|
+
return yield* Effect.tryPromise({
|
33
|
+
try: () => response.text(),
|
34
|
+
catch: (error) => new Error(`Failed to read response: ${error}`),
|
35
|
+
});
|
36
|
+
});
|
37
|
+
// Write HTML to file system
|
38
|
+
const writeHtmlFile = (outputPath, html) => Effect.gen(function* () {
|
39
|
+
const fs = yield* FileSystem.FileSystem;
|
40
|
+
const path = yield* Path.Path;
|
41
|
+
const dir = path.dirname(outputPath);
|
42
|
+
yield* fs.makeDirectory(dir, { recursive: true });
|
43
|
+
yield* fs.writeFileString(outputPath, html);
|
44
|
+
});
|
45
|
+
// Process a single route
|
46
|
+
const processRoute = (route, serverPort, outputDir) => Effect.gen(function* () {
|
47
|
+
const path = yield* Path.Path;
|
48
|
+
// Fetch the page from the server
|
49
|
+
const url = `http://localhost:${serverPort}${route}`;
|
50
|
+
const html = yield* fetchPage(url).pipe(Effect.mapError(error => new RouteProcessingError({ route, cause: error })));
|
51
|
+
// Determine output file path
|
52
|
+
const outputPath = path.join(outputDir, route === '/' ? 'index.html' : `${route.slice(1)}/index.html`);
|
53
|
+
// Write the HTML file
|
54
|
+
yield* writeHtmlFile(outputPath, html).pipe(Effect.mapError(error => new RouteProcessingError({ route, cause: error })));
|
55
|
+
return route;
|
56
|
+
});
|
26
57
|
const handlers = {
|
27
58
|
GeneratePages: ({ routes, serverPort, outputDir }) => Effect.gen(function* () {
|
28
|
-
|
29
|
-
const startTime = Date.now();
|
30
|
-
let processedCount = 0;
|
31
|
-
debug(`Starting batch generation`, {
|
59
|
+
yield* Effect.logDebug(`Starting batch generation`).pipe(Effect.annotateLogs({
|
32
60
|
totalRoutes: routes.length,
|
33
61
|
serverPort,
|
34
|
-
});
|
35
|
-
// Process
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}
|
45
|
-
const html = await response.text();
|
46
|
-
// Determine output file path
|
47
|
-
const outputPath = path.join(outputDir, route === '/' ? 'index.html' : `${route.slice(1)}/index.html`);
|
48
|
-
// Ensure directory exists
|
49
|
-
const dir = path.dirname(outputPath);
|
50
|
-
await fs.mkdir(dir, { recursive: true });
|
51
|
-
// Write the HTML file
|
52
|
-
await fs.writeFile(outputPath, html, 'utf-8');
|
53
|
-
processedCount++;
|
54
|
-
// Log progress every 5 routes or on last route
|
55
|
-
if (processedCount % 5 === 0 || processedCount === routes.length) {
|
56
|
-
debug(`Progress`, {
|
57
|
-
processedCount,
|
58
|
-
totalRoutes: routes.length,
|
59
|
-
serverPort,
|
60
|
-
});
|
61
|
-
}
|
62
|
-
},
|
63
|
-
catch: (error) => {
|
64
|
-
debug(`Failed to process route`, { route, error });
|
65
|
-
return new RouteProcessingError({ route, cause: error });
|
66
|
-
},
|
67
|
-
});
|
68
|
-
}
|
62
|
+
}));
|
63
|
+
// Process all routes with timing, collecting both successes and failures
|
64
|
+
const [duration, results] = yield* Effect.forEach(routes, (route, index) => processRoute(route, serverPort, outputDir).pipe(Effect.tap(() =>
|
65
|
+
// Log progress every 5 routes
|
66
|
+
(index + 1) % 5 === 0 || index === routes.length - 1
|
67
|
+
? Effect.logDebug(`Progress: ${index + 1}/${routes.length} routes processed`)
|
68
|
+
: Effect.void), Effect.either), { concurrency: 1 }).pipe(Effect.timed);
|
69
|
+
// Partition results into successes and failures
|
70
|
+
const [failures, successes] = Array.partition(results, Either.isRight);
|
71
|
+
const processedCount = successes.length;
|
69
72
|
const result = {
|
70
|
-
success:
|
73
|
+
success: failures.length === 0,
|
71
74
|
processedCount,
|
72
|
-
duration:
|
75
|
+
duration: Duration.toMillis(duration),
|
73
76
|
memoryUsed: process.memoryUsage().heapUsed,
|
77
|
+
...(failures.length > 0 && {
|
78
|
+
error: `Failed to generate ${failures.length} out of ${routes.length} routes`,
|
79
|
+
failures: failures.map((f) => ({
|
80
|
+
route: f.left.route,
|
81
|
+
error: f.left.cause instanceof Error ? f.left.cause.message : String(f.left.cause),
|
82
|
+
})),
|
83
|
+
}),
|
74
84
|
};
|
75
|
-
|
85
|
+
yield* Effect.logDebug(`Batch generation complete`).pipe(Effect.annotateLogs(result));
|
76
86
|
return result;
|
77
|
-
})
|
78
|
-
success: false,
|
79
|
-
processedCount: 0,
|
80
|
-
duration: Date.now() - Date.now(),
|
81
|
-
memoryUsed: process.memoryUsage().heapUsed,
|
82
|
-
error: error instanceof Error ? error.message : String(error),
|
83
|
-
}))),
|
87
|
+
}),
|
84
88
|
};
|
85
89
|
// ============================================================================
|
86
90
|
// Worker Runner
|
87
91
|
// ============================================================================
|
88
92
|
// Run the worker
|
89
|
-
WorkerRunner.launch(Layer.provide(WorkerRunner.layerSerialized(PageMessage, handlers), Layer.
|
93
|
+
WorkerRunner.launch(Layer.provide(WorkerRunner.layerSerialized(PageMessage, handlers), Layer.mergeAll(NodeWorkerRunner.layer, NodeContext.layer))).pipe(NodeRuntime.runMain);
|
90
94
|
//# sourceMappingURL=page-generator.worker.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"page-generator.worker.js","sourceRoot":"","sources":["../../../../src/api/builder/ssg/page-generator.worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,
|
1
|
+
{"version":3,"file":"page-generator.worker.js","sourceRoot":"","sources":["../../../../src/api/builder/ssg/page-generator.worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,YAAY,EAAE,MA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CAAA;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAC;CACL,CAAA;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,iBAAiB;AACjB,YAAY,CAAC,MAAM,CACjB,KAAK,CAAC,OAAO,CACX,YAAY,CAAC,eAAe,CAAC,WAAW,EAAE,QAAQ,CAAC,EACnD,KAAK,CAAC,QAAQ,CACZ,gBAAgB,CAAC,KAAK,EACtB,WAAW,CAAC,KAAK,CAClB,CACF,CACF,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA"}
|
@@ -2,48 +2,48 @@
|
|
2
2
|
* Worker that runs a Polen server for SSG.
|
3
3
|
* This is executed in a child process using Effect Worker API.
|
4
4
|
*/
|
5
|
-
import { debugPolen } from '#singletons/debug';
|
6
5
|
import { WorkerRunner } from '@effect/platform';
|
7
6
|
import { NodeRuntime, NodeWorkerRunner } from '@effect/platform-node';
|
8
|
-
import { Duration, Effect, Layer, Scope } from 'effect';
|
7
|
+
import { Duration, Effect, Layer, Ref, Scope } from 'effect';
|
9
8
|
import { spawn } from 'node:child_process';
|
10
9
|
import { ServerMessage } from './worker-messages.js';
|
11
|
-
|
12
|
-
|
13
|
-
let serverProcess = null;
|
10
|
+
// Store the server process reference for cleanup
|
11
|
+
const serverProcessRef = Ref.unsafeMake(null);
|
14
12
|
// ============================================================================
|
15
13
|
// Handlers
|
16
14
|
// ============================================================================
|
17
15
|
const handlers = {
|
18
16
|
StartServer: ({ serverPath, port }) => Effect.gen(function* () {
|
19
17
|
// If there's already a server running, stop it first
|
20
|
-
|
21
|
-
|
18
|
+
const existingProcess = yield* Ref.get(serverProcessRef);
|
19
|
+
if (existingProcess) {
|
20
|
+
existingProcess.kill('SIGTERM');
|
22
21
|
yield* Effect.sleep(Duration.millis(500));
|
23
|
-
if (!
|
24
|
-
|
22
|
+
if (!existingProcess.killed) {
|
23
|
+
existingProcess.kill('SIGKILL');
|
25
24
|
}
|
26
|
-
|
25
|
+
yield* Ref.set(serverProcessRef, null);
|
27
26
|
}
|
28
27
|
// Start the server process
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
yield* Effect.logDebug(`Starting server with command: node ${serverPath}`);
|
29
|
+
const proc = yield* Effect.sync(() => {
|
30
|
+
const serverProc = spawn('node', [serverPath], {
|
32
31
|
env: {
|
33
32
|
...process.env,
|
34
33
|
PORT: port.toString(),
|
35
34
|
},
|
36
35
|
stdio: ['ignore', 'pipe', 'pipe'],
|
37
36
|
});
|
38
|
-
|
39
|
-
|
37
|
+
// Log server output
|
38
|
+
serverProc.stdout?.on('data', (data) => {
|
39
|
+
Effect.logDebug(`[Server ${port}] stdout: ${data.toString().trim()}`).pipe(Effect.runSync);
|
40
40
|
});
|
41
|
-
|
42
|
-
|
41
|
+
serverProc.stderr?.on('data', (data) => {
|
42
|
+
Effect.logDebug(`[Server ${port}] stderr: ${data.toString().trim()}`).pipe(Effect.runSync);
|
43
43
|
});
|
44
|
-
return
|
44
|
+
return serverProc;
|
45
45
|
});
|
46
|
-
|
46
|
+
yield* Ref.set(serverProcessRef, proc);
|
47
47
|
// Wait for server to be ready with proper interruption support
|
48
48
|
const waitForReady = Effect.async((resume) => {
|
49
49
|
// Handle process errors
|
@@ -64,7 +64,7 @@ const handlers = {
|
|
64
64
|
try {
|
65
65
|
const response = await fetch(`http://localhost:${port}/`);
|
66
66
|
if (response.ok || response.status === 404) {
|
67
|
-
|
67
|
+
Effect.logDebug(`[Server ${port}] Ready!`).pipe(Effect.runSync);
|
68
68
|
if (checkInterval)
|
69
69
|
clearInterval(checkInterval);
|
70
70
|
proc.removeListener('error', errorHandler);
|
@@ -92,30 +92,24 @@ const handlers = {
|
|
92
92
|
});
|
93
93
|
// Apply timeout with proper Effect interruption
|
94
94
|
yield* waitForReady.pipe(Effect.timeout(Duration.seconds(30)), Effect.catchTag('TimeoutException', () => Effect.die(new Error(`Server on port ${port} failed to start within 30 seconds`))));
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
if (serverProcess && !serverProcess.killed) {
|
103
|
-
serverProcess.kill('SIGKILL');
|
104
|
-
}
|
105
|
-
serverProcess = null;
|
106
|
-
}, 100);
|
95
|
+
yield* Effect.logDebug(`Server on port ${port} started successfully`);
|
96
|
+
}),
|
97
|
+
StopServer: ({ port }) => Effect.gen(function* () {
|
98
|
+
const serverProc = yield* Ref.get(serverProcessRef);
|
99
|
+
if (serverProc) {
|
100
|
+
if (port !== undefined) {
|
101
|
+
yield* Effect.logDebug(`Stopping server on port ${port}`);
|
107
102
|
}
|
108
|
-
|
109
|
-
}).pipe(Effect.scoped),
|
110
|
-
StopServer: () => Effect.gen(function* () {
|
111
|
-
if (serverProcess) {
|
112
|
-
serverProcess.kill('SIGTERM');
|
103
|
+
serverProc.kill('SIGTERM');
|
113
104
|
// Give it time to shut down gracefully
|
114
105
|
yield* Effect.sleep(Duration.millis(500));
|
115
|
-
if (!
|
116
|
-
|
106
|
+
if (!serverProc.killed) {
|
107
|
+
serverProc.kill('SIGKILL');
|
108
|
+
}
|
109
|
+
yield* Ref.set(serverProcessRef, null);
|
110
|
+
if (port !== undefined) {
|
111
|
+
yield* Effect.logDebug(`Server on port ${port} stopped`);
|
117
112
|
}
|
118
|
-
serverProcess = null;
|
119
113
|
}
|
120
114
|
}),
|
121
115
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"server-runner.worker.js","sourceRoot":"","sources":["../../../../src/api/builder/ssg/server-runner.worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,
|
1
|
+
{"version":3,"file":"server-runner.worker.js","sourceRoot":"","sources":["../../../../src/api/builder/ssg/server-runner.worker.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACrE,OAAO,EA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CAAC,SAAS,CAAC,CAAA;YAC5B,CAAC;YACD,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC,CAAA;YACtC,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,IAAI,UAAU,CAAC,CAAA;YAC1D,CAAC;QACH,CAAC;IACH,CAAC,CAAC;CACL,CAAA;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,iBAAiB;AACjB,YAAY,CAAC,MAAM,CACjB,KAAK,CAAC,OAAO,CACX,YAAY,CAAC,eAAe,CAAC,aAAa,EAAE,QAAQ,CAAC,EACrD,gBAAgB,CAAC,KAAK,CACvB,CACF,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA"}
|
@@ -5,6 +5,10 @@ declare const GenerateResultSchema: S.Struct<{
|
|
5
5
|
duration: typeof S.Number;
|
6
6
|
memoryUsed: typeof S.Number;
|
7
7
|
error: S.optional<typeof S.String>;
|
8
|
+
failures: S.optional<S.Array$<S.Struct<{
|
9
|
+
route: typeof S.String;
|
10
|
+
error: typeof S.String;
|
11
|
+
}>>>;
|
8
12
|
}>;
|
9
13
|
export type GenerateResult = S.Schema.Type<typeof GenerateResultSchema>;
|
10
14
|
declare const StartServerMessage_base: S.TaggedRequestClass<StartServerMessage, "StartServer", {
|
@@ -17,6 +21,8 @@ export declare class StartServerMessage extends StartServerMessage_base {
|
|
17
21
|
}
|
18
22
|
declare const StopServerMessage_base: S.TaggedRequestClass<StopServerMessage, "StopServer", {
|
19
23
|
readonly _tag: S.tag<"StopServer">;
|
24
|
+
} & {
|
25
|
+
port: S.optional<typeof S.Number>;
|
20
26
|
}, typeof S.Void, typeof S.Never>;
|
21
27
|
export declare class StopServerMessage extends StopServerMessage_base {
|
22
28
|
}
|
@@ -34,6 +40,10 @@ declare const GeneratePagesMessage_base: S.TaggedRequestClass<GeneratePagesMessa
|
|
34
40
|
duration: typeof S.Number;
|
35
41
|
memoryUsed: typeof S.Number;
|
36
42
|
error: S.optional<typeof S.String>;
|
43
|
+
failures: S.optional<S.Array$<S.Struct<{
|
44
|
+
route: typeof S.String;
|
45
|
+
error: typeof S.String;
|
46
|
+
}>>>;
|
37
47
|
}>, typeof S.String>;
|
38
48
|
export declare class GeneratePagesMessage extends GeneratePagesMessage_base {
|
39
49
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"worker-messages.d.ts","sourceRoot":"","sources":["../../../../src/api/builder/ssg/worker-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAYxC,QAAA,MAAM,oBAAoB
|
1
|
+
{"version":3,"file":"worker-messages.d.ts","sourceRoot":"","sources":["../../../../src/api/builder/ssg/worker-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,sBAAsB,CAAA;AAYxC,QAAA,MAAM,oBAAoB;;;;;;;;;;EAcxB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,oBAAoB,CAAC,CAAA;;;;;;;AAMvE,qBAAa,kBAAmB,SAAQ,uBAUvC;CAAG;;;;;;AAEJ,qBAAa,iBAAkB,SAAQ,sBAStC;CAAG;AAEJ,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,iBAAiB,CAAA;AAClE,eAAO,MAAM,aAAa,gEAAiD,CAAA;;;;;;;;;;;;;;;;;;AAM3E,qBAAa,oBAAqB,SAAQ,yBAWzC;CAAG;AAEJ,MAAM,MAAM,WAAW,GAAG,oBAAoB,CAAA;AAC9C,eAAO,MAAM,WAAW,6BAAgC,CAAA"}
|