@@ -36,28 +36,21 @@ import path from 'path';
36
36
import asyncPool from 'tiny-async-pool' ;
37
37
import { makeUnifiedBookLoader } from '../../src/app/content/utils' ;
38
38
import { assertDefined } from '../../src/app/utils' ;
39
- import config from '../../src/config' ;
40
39
import BOOKS from '../../src/config.books' ;
41
40
import createArchiveLoader from '../../src/gateways/createArchiveLoader' ;
42
41
import { getBooksConfigSync } from '../../src/gateways/createBookConfigLoader' ;
43
42
import createOSWebLoader from '../../src/gateways/createOSWebLoader' ;
44
43
import { readFile } from '../../src/helpers/fileUtils' ;
45
44
import { globalMinuteCounter , prepareBookPages } from './contentPages' ;
46
- import { SerializedBookMatch , SerializedPageMatch } from './contentRoutes' ;
45
+ import { SerializedPageMatch } from './contentRoutes' ;
47
46
import createRedirects from './createRedirects' ;
48
47
import './logUnhandledRejectionsAndExit' ;
49
48
import renderManifest from './renderManifest' ;
50
- import { SitemapPayload } from './sitemap' ;
51
-
52
- const {
53
- ARCHIVE_URL ,
54
- CODE_VERSION ,
55
- OS_WEB_URL ,
56
- REACT_APP_OS_WEB_API_URL ,
57
- RELEASE_ID ,
58
- } = config ;
59
-
60
- assertDefined ( RELEASE_ID , 'REACT_APP_RELEASE_ID environment variable must be set' ) ;
49
+ import { SitemapPayload , renderAndSaveSitemapIndex } from './sitemap' ;
50
+ import { writeS3ReleaseXmlFile } from './fileUtils' ;
51
+ import { renderAndSaveContentManifest } from './contentManifest' ;
52
+ import { ARCHIVE_URL , OS_WEB_URL , REACT_APP_OS_WEB_API_URL , CODE_VERSION } from '../../src/config' ;
53
+ import { RELEASE_ID , WORK_REGION , BUCKET_NAME , BUCKET_REGION , PUBLIC_URL } from './constants' ;
61
54
62
55
// Increasing this too much can lead to connection issues and greater memory usage in the manager
63
56
const MAX_CONCURRENT_BOOKS = 5 ;
@@ -73,11 +66,6 @@ const PRERENDER_TIMEOUT_SECONDS = 3600;
73
66
const WORKERS_STACK_CREATE_TIMEOUT_SECONDS = 300 ;
74
67
const WORKERS_STACK_DELETE_TIMEOUT_SECONDS = WORKERS_STACK_CREATE_TIMEOUT_SECONDS ;
75
68
76
- const BUCKET_NAME = process . env . BUCKET_NAME || 'sandbox-unified-web-primary' ;
77
- const BUCKET_REGION = process . env . BUCKET_REGION || 'us-east-1' ;
78
- const PUBLIC_URL = process . env . PUBLIC_URL || `/rex/releases/${ RELEASE_ID } ` ;
79
- const WORK_REGION = process . env . WORK_REGION || 'us-east-2' ;
80
-
81
69
// Docker does not accept forward slashes in the image tag
82
70
const IMAGE_TAG = process . env . IMAGE_TAG || `${ RELEASE_ID . replace ( / \/ / g, '-' ) } ` ;
83
71
@@ -86,7 +74,6 @@ const sqsClient = new SQSClient({ region: WORK_REGION });
86
74
87
75
type PageTask = { payload : SerializedPageMatch , type : 'page' } ;
88
76
type SitemapTask = { payload : SitemapPayload , type : 'sitemap' } ;
89
- type SitemapIndexTask = { payload : SerializedBookMatch [ ] , type : 'sitemapIndex' } ;
90
77
91
78
const booksConfig = getBooksConfigSync ( ) ;
92
79
const archiveLoader = createArchiveLoader ( {
@@ -288,8 +275,7 @@ async function getQueueUrls(workersStackName: string) {
288
275
class Stats {
289
276
public pages = 0 ;
290
277
public sitemaps = 0 ;
291
- public sitemapIndexes = 0 ;
292
- get total ( ) { return this . pages + this . sitemaps + this . sitemapIndexes ; }
278
+ get total ( ) { return this . pages + this . sitemaps ; }
293
279
}
294
280
295
281
function makePrepareAndQueueBook ( workQueueUrl : string , stats : Stats ) {
@@ -347,11 +333,7 @@ function makePrepareAndQueueBook(workQueueUrl: string, stats: Stats) {
347
333
348
334
console . log ( `[${ book . title } ] Sitemap queued` ) ;
349
335
350
- // Used in the sitemap index
351
- return {
352
- params : { book : { slug : book . slug } } ,
353
- state : { bookUid : book . id , bookVersion : book . version } ,
354
- } ;
336
+ return book ;
355
337
} ;
356
338
}
357
339
@@ -371,14 +353,10 @@ async function queueWork(workQueueUrl: string) {
371
353
`All ${ stats . pages } page prerendering jobs and all ${ stats . sitemaps } sitemap jobs queued`
372
354
) ;
373
355
374
- await sendWithRetries ( sqsClient , new SendMessageCommand ( {
375
- MessageBody : JSON . stringify ( { payload : books , type : 'sitemapIndex' } as SitemapIndexTask ) ,
376
- QueueUrl : workQueueUrl ,
377
- } ) ) ;
378
-
379
- stats . sitemapIndexes = 1 ;
380
-
381
- console . log ( '1 sitemap index job queued' ) ;
356
+ await Promise . all ( [
357
+ renderAndSaveSitemapIndex ( writeS3ReleaseXmlFile , books ) ,
358
+ renderAndSaveContentManifest ( writeS3ReleaseXmlFile , books ) ,
359
+ ] ) ;
382
360
383
361
return stats ;
384
362
}
@@ -463,8 +441,8 @@ async function finishRendering(stats: Stats) {
463
441
const elapsedMinutes = globalMinuteCounter ( ) ;
464
442
465
443
console . log (
466
- `Prerender complete in ${ elapsedMinutes } minutes. Rendered ${ stats . pages } pages, ${
467
- stats . sitemaps } sitemaps and ${ stats . sitemapIndexes } sitemap index . ${
444
+ `Prerender complete in ${ elapsedMinutes } minutes. Rendered ${ stats . pages } pages, and ${
445
+ stats . sitemaps } sitemaps. ${
468
446
stats . total / elapsedMinutes } ppm`
469
447
) ;
470
448
}
0 commit comments