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