Change unfurler puppeteer config toggle to ENABLED
This commit is contained in:
		
							parent
							
								
									c289f821e4
								
							
						
					
					
						commit
						5a339c382f
					
				| @ -9,8 +9,8 @@ | |||||||
|     "NETWORK": "bitcoin" // "bitcoin" | "liquid" | "bisq" (optional - defaults to "bitcoin") |     "NETWORK": "bitcoin" // "bitcoin" | "liquid" | "bisq" (optional - defaults to "bitcoin") | ||||||
|   }, |   }, | ||||||
|   "PUPPETEER": { |   "PUPPETEER": { | ||||||
|     "DISABLE": false, // optional, boolean, disables puppeteer and /render endpoints |     "ENABLED": false, // optional, boolean, enables puppeteer and /render endpoints (default true) | ||||||
|     "CLUSTER_SIZE": 2, |     "CLUSTER_SIZE": 2, // maximum number of parallel chromium pages. CLUSTER_SIZE=0 implies ENABLED=false | ||||||
|     "EXEC_PATH": "/usr/local/bin/chrome", // optional |     "EXEC_PATH": "/usr/local/bin/chrome", // optional | ||||||
|     "MAX_PAGE_AGE": 86400, // maximum lifetime of a page session (in seconds) |     "MAX_PAGE_AGE": 86400, // maximum lifetime of a page session (in seconds) | ||||||
|     "RENDER_TIMEOUT": 3000, // timeout for preview image rendering (in ms) (optional) |     "RENDER_TIMEOUT": 3000, // timeout for preview image rendering (in ms) (optional) | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ interface IConfig { | |||||||
|     NETWORK?: string; |     NETWORK?: string; | ||||||
|   }; |   }; | ||||||
|   PUPPETEER: { |   PUPPETEER: { | ||||||
|     DISABLE: boolean; |     ENABLED: boolean; | ||||||
|     CLUSTER_SIZE: number; |     CLUSTER_SIZE: number; | ||||||
|     EXEC_PATH?: string; |     EXEC_PATH?: string; | ||||||
|     MAX_PAGE_AGE?: number; |     MAX_PAGE_AGE?: number; | ||||||
| @ -29,7 +29,7 @@ const defaults: IConfig = { | |||||||
|     'HTTP_PORT': 4200, |     'HTTP_PORT': 4200, | ||||||
|   }, |   }, | ||||||
|   'PUPPETEER': { |   'PUPPETEER': { | ||||||
|     'DISABLE': false, |     'ENABLED': true, | ||||||
|     'CLUSTER_SIZE': 1, |     'CLUSTER_SIZE': 1, | ||||||
|   }, |   }, | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -13,6 +13,8 @@ if (config.PUPPETEER.EXEC_PATH) { | |||||||
|   puppeteerConfig.executablePath = config.PUPPETEER.EXEC_PATH; |   puppeteerConfig.executablePath = config.PUPPETEER.EXEC_PATH; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | const puppeteerEnabled = config.PUPPETEER.ENABLED && (config.PUPPETEER.CLUSTER_SIZE > 0); | ||||||
|  | 
 | ||||||
| class Server { | class Server { | ||||||
|   private server: http.Server | undefined; |   private server: http.Server | undefined; | ||||||
|   private app: Application; |   private app: Application; | ||||||
| @ -24,7 +26,7 @@ class Server { | |||||||
|   constructor() { |   constructor() { | ||||||
|     this.app = express(); |     this.app = express(); | ||||||
|     this.mempoolHost = config.MEMPOOL.HTTP_HOST + (config.MEMPOOL.HTTP_PORT ? ':' + config.MEMPOOL.HTTP_PORT : ''); |     this.mempoolHost = config.MEMPOOL.HTTP_HOST + (config.MEMPOOL.HTTP_PORT ? ':' + config.MEMPOOL.HTTP_PORT : ''); | ||||||
|     this.secureHost = this.mempoolHost.startsWith('https'); |     this.secureHost = config.SERVER.HOST.startsWith('https'); | ||||||
|     this.network = config.MEMPOOL.NETWORK || 'bitcoin'; |     this.network = config.MEMPOOL.NETWORK || 'bitcoin'; | ||||||
|     this.startServer(); |     this.startServer(); | ||||||
|   } |   } | ||||||
| @ -39,7 +41,7 @@ class Server { | |||||||
|       .use(express.text()) |       .use(express.text()) | ||||||
|       ; |       ; | ||||||
| 
 | 
 | ||||||
|     if (!config.PUPPETEER.DISABLE) { |     if (puppeteerEnabled) { | ||||||
|       this.cluster = await Cluster.launch({ |       this.cluster = await Cluster.launch({ | ||||||
|           concurrency: ReusablePage, |           concurrency: ReusablePage, | ||||||
|           maxConcurrency: config.PUPPETEER.CLUSTER_SIZE, |           maxConcurrency: config.PUPPETEER.CLUSTER_SIZE, | ||||||
| @ -68,7 +70,7 @@ class Server { | |||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   setUpRoutes() { |   setUpRoutes() { | ||||||
|     if (!config.PUPPETEER.DISABLE) { |     if (puppeteerEnabled) { | ||||||
|       this.app.get('/render*', async (req, res) => { return this.renderPreview(req, res) }) |       this.app.get('/render*', async (req, res) => { return this.renderPreview(req, res) }) | ||||||
|     } else { |     } else { | ||||||
|       this.app.get('/render*', async (req, res) => { return this.renderDisabled(req, res) }) |       this.app.get('/render*', async (req, res) => { return this.renderDisabled(req, res) }) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user