Thanks that worked :)
Sahil333
@Sahil333
Posts made by Sahil333
-
Jsreport writing logs to the file even after removing file transport from jsreport.config.json
I wanted to remove the logs written to the file logs/reporter.logs as they are collected from the console itself. So, I removed the file logging from the jsreport.config.json, removed the logs folder and restarted the server but I see the logs/reporter.log again.
Here is my config file.{ "extensions": { "authentication": { "cookieSession": { "secret": "<your strong secret here>" }, "admin": { "username": "admin", "password": "password" }, "enabled": false }, "scripts": { "timeout": 40000, "strategy": "http-server", "numberOfWorkers": 2 }, "sample-template": { "createSamples": false } }, "httpPort": 8088, "store": { "provider": "fs" }, "blobStorage": { "provider": "fs" }, "logger": { "console": { "transport": "console", "level": "debug" } }, "allowLocalFilesAccess": true, "templatingEngines": { "timeout": 10000, "strategy": "http-server", "numberOfWorkers": 2 }, "chrome": { "timeout": 40000, "strategy": "chrome-pool", "numberOfWorkers": 2 }, "tasks": { "timeout": 40000, "strategy": "http-server", "numberOfWorkers": 2 } }
-
RE: Pdf Rendering and merging taking a lot of time
Is there any way to know the page count of pdf to be rendered from html before rendering? All the data is already embedded in html
-
Pdf Rendering and merging taking a lot of time
I am looking for a better solution to merge a set of htmls into a single pdf. Each html can have any number of pages when rendered to pdf. When the final pdf is printed on a printer with two-page side printing option, each html should be printed as a single unit i.e. no printed page should have content from two htmls. Currently, I am rendering each html to pdf, using pdfjs to get pageCount, then merging each html one by one with a single blank page in between, if the last html had an odd number of pages.
I am usingjsreport.render
for rendering,jsreport-pdf-utils/lib/utils/addPages
for merging, andpdfjs.ExternalDocument
for pageCount.
Set of html to pdf conversion is done withPromise.all
, so rendering is not a bottleneck when using http-server strategy but the merging is what takes most of time (I'll have to check for exact numbers).
Can you tell me a better approach for this problem? Can I do this in a single operation of rendering with injecting blank page where necessary? -
RE: Fs store sync triggering a lot like 50 times
It worked! But
jsreport.close()
closes the express server as well on which jsreport is running. So after the promise ofjsreport.close()
is resolved when I doserver.shuttdown()
, I get an errorserver is not running
. -
RE: Fs store sync triggering a lot like 50 times
OK, I have written a simple nodejs application with express and hosting jsreport studio on an endpoint '/v1' using jsreport nodejs sdk. Apart from that, I have two other endpoints, one to render a given template and other to merge a list of documents.
The
sever.shutdown
is the same as theserver.close
, I used this package https://www.npmjs.com/package/http-shutdown for this (I used server.close as well but faced the same problem). It is defined in the entry point of my applicationserver.js
. I run the application withnode server.js
.const signals = { SIGINT: 2, SIGTERM: 15, }; // Do any necessary shutdown logic for our application here const shutdown = (signal, value) => { logger.info(`Shutting down server by ${signal}:${value}...`); server.shutdown((err) => { if (err) { logger.error( `STOPPING_SERVER: Stopping process to recover from unhandled exception.${err}`, ); process.exit(1); } else { logger.info('Shut down server successfuly'); process.exit(0); } }); }; // Create a listener for each of the signals that we want to handle Object.keys(signals).forEach((signal) => { process.on(signal, () => { logger.info(`Process received a ${signal} signal`); shutdown(signal, signals[signal]); }); });
I'll elaborate on the two cases:
Case 1: Call
process.exit()
in the callback ofserver.shutdown()
1. I start the server.
2. Send a request on one of the endpoints and I see no fs store reload
3. Close the server.
4. Start the server again
5. Send request again and I see no fs store reloadCase 2: Does not call
process.exit()
in the callback ofserver.shutdown()
1. I start the server.
2. Send a request on one of the endpoints and I see no fs store reload
3. Close the server.
4. Start the server again
5. Send request again and I start seeing fs store reload
6. Now, on every subsequent restart, I see fs store reload after sending the request with more and more number of fs store reload. -
RE: Fs store sync triggering a lot like 50 times
Ok, after restarting the system both the issue disappeared. I got the culprit of the issue. I have a mechanism for the graceful shutdown of the server as given below. The error doesn't appear if I do process.exit() after the shutdown. But the error starts to appear after commenting process.exit(0). It seems some background process remains alive even after doing shutdown and process.exit(0) closes that process. Is this behavior ok?
const shutdown = (signal, value) => { logger.info(`Shutting down server by ${signal}:${value}...`); server.shutdown((err) => { if (err) { logger.error( `STOPPING_SERVER: Stopping process to recover from unhandled exception.${err}`, ); process.exit(1); } else { logger.info('Shut down server successfuly'); process.exit(0); } }); };
PS. I am using nodemon for development purposes.
-
RE: Fs store sync triggering a lot like 50 times
No, there is only a single instance node. I ran
lsof -i tcp:8080
and got this. I'll restart my system and try again to be sure.Google 62626 sahil 27u IPv6 0xe2cf8c914865fd6d 0t0 TCP localhost:56153->localhost:http-alt (CLOSE_WAIT)
Google 62626 sahil 30u IPv6 0xe2cf8c9148661c0d 0t0 TCP localhost:56154->localhost:http-alt (CLOSE_WAIT)
Google 62626 sahil 36u IPv6 0xe2cf8c9148662e6d 0t0 TCP localhost:56155->localhost:http-alt (CLOSE_WAIT)
Google 62626 sahil 38u IPv6 0xe2cf8c914866348d 0t0 TCP localhost:56156->localhost:http-alt (CLOSE_WAIT)
Google 62626 sahil 40u IPv6 0xe2cf8c914865eb0d 0t0 TCP localhost:56157->localhost:http-alt (CLOSE_WAIT)
Google 62626 sahil 44u IPv6 0xe2cf8c9138078fcd 0t0 TCP localhost:56158->localhost:http-alt (CLOSE_WAIT)
node 98371 sahil 24u IPv6 0xe2cf8c91486609ad 0t0 TCP *:http-alt (LISTEN)
Also, when I set literally any option for "fs-store" in extensions, I start getting this error and without it, no such error.
2019-12-11T05:43:21.084Z INFO /v1/socket.io/?EIO=3&transport=polling&t=MxpUxJt 404 - Correlation-Id - 23ceccb0-1bd9-11ea-99e7-7101baec6f0c - 0.916 ms
-
Fs store sync triggering a lot like 50 times
I was not getting this before but from this evening I am getting the below log when processing the render request. Initially, I was getting this 2-3 times but as I repeated the request its number grew.
2019-12-10T12:57:29.918Z - debug: fs store sync is triggering reload, because /Users/sahil/Tesco/document-service/data/settings was changed by other process 2019-12-10T12:57:29.918Z - info: fs store is loading data
-
RE: reportName not working. Reports are stored with random name.
Great. Thanks for the help :D