Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logger instantiates itself with default settings, causing crash on server environments that do not allow file write permissions #6179

Closed
kevflynn opened this issue Nov 4, 2019 · 3 comments · Fixed by #6186

Comments

@kevflynn
Copy link

kevflynn commented Nov 4, 2019

Issue Description

When you import the parse-server sdk, the logger file instantiates the file logger with default settings, causing the nodejs application to crash if the file system doesn't allow write permissions. This is irrespective of instantiating parse-server with custom config. The problem appears to be in the logger.js file on the line:

let logger = defaultLogger();

Steps to reproduce

  1. Create a 'logs' directory with read only permission at the base of the project directory './logs'
  2. Import the parse-server module with express running
  3. The nodejs/express server will crash because the './logs' directory is read only.

Expected Results

The server should run and the logger should only instantiate once I instantiate the parse-server with optional config settings

Actual Outcome

The logger is instantiated even before I instantiate the parse-server and have a chance to pass my own config settings causing a crash if write permissions are not allowed

Environment Setup

  • Server
    • parse-server version (Be specific! Don't say 'latest'.) : 3.9.0
    • Operating System: Parse server hosted by google app engine nodejs standard environment
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): Google App Engine Standard Environment, or localhost without file write permissions

Logs/Trace

{ insertId: "5dbc64ea00010957b7762996" labels: { clone_id: "00c61b117c37e953a744445117cca35dda5c28e7dddc8cd7e6c4936a7ef8cda1c3d442bca9" } logName: "projects/communityroot/logs/stderr" receiveTimestamp: "2019-11-01T17:01:30.156658889Z" resource: { labels: { module_id: "api" project_id: "communityroot" version_id: "20191101t120829" zone: "us17" } type: "gae_app" } textPayload: "Error: EROFS: read-only file system, mkdir '/srv/logs/' at Object.mkdirSync (fs.js:757:3) at /srv/node_modules/file-stream-rotator/FileStreamRotator.js:515:20 at Array.reduce (<anonymous>) at mkDirForFile (/srv/node_modules/file-stream-rotator/FileStreamRotator.js:503:27) at Object.FileStreamRotator.getStream (/srv/node_modules/file-stream-rotator/FileStreamRotator.js:421:5) at new DailyRotateFile (/srv/node_modules/winston-daily-rotate-file/daily-rotate-file.js:83:57) at configureTransports (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLogger.js:41:27) at configureLogger (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLogger.js:109:3) at new WinstonLoggerAdapter (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLoggerAdapter.js:19:42) at defaultLogger (/srv/node_modules/parse-server/lib/logger.js:24:19) at Object.<anonymous> (/srv/node_modules/parse-server/lib/logger.js:28:14) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3)" timestamp: "2019-11-01T17:01:30.067927Z" }

dplewis added a commit that referenced this issue Nov 5, 2019
Fixes: #6179

Removes unnessary logs
@dplewis
Copy link
Member

dplewis commented Nov 5, 2019

@kevflynn I just realized that your issue is your root folder is readonly.
EROFS: read-only file system, mkdir '/srv/logs/' in your case /srv.

Steps to reproduce

  1. Delete any logs directory.
  2. make project directory read-only.
  3. Import the parse-server module with express running
  4. The nodejs/express server will crash because it can't create ./logs in a readonly directory.

If your logs folder was read only you would have seen an error like

Error: EACCES: permission denied, open '/Users/parse-server/logs/parse-server.info.2019-11-05'

dplewis added a commit that referenced this issue Nov 7, 2019
* Fix #6179 Initializing default logger

Fixes: #6179

Removes unnessary logs

* fix typo

* if error just write to console
@stewones
Copy link
Contributor

stewones commented Dec 6, 2019

when this is going to be released?

same problem here

Error: EROFS: read-only file system, mkdir '/srv/logs/' at Object.mkdirSync (fs.js:757:3) at /srv/node_modules/file-stream-rotator/FileStreamRotator.js:515:20 at Array.reduce (<anonymous>) at mkDirForFile (/srv/node_modules/file-stream-rotator/FileStreamRotator.js:503:27) at Object.FileStreamRotator.getStream (/srv/node_modules/file-stream-rotator/FileStreamRotator.js:421:5) at new DailyRotateFile (/srv/node_modules/winston-daily-rotate-file/daily-rotate-file.js:83:57) at configureTransports (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLogger.js:41:27) at configureLogger (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLogger.js:109:3) at new WinstonLoggerAdapter (/srv/node_modules/parse-server/lib/Adapters/Logger/WinstonLoggerAdapter.js:19:42) at defaultLogger (/srv/node_modules/parse-server/lib/logger.js:24:19)

@stewones
Copy link
Contributor

stewones commented Dec 6, 2019

I've tried to disable it on server initialisation as said in docs but no luck

logsFolder: null

that is still logging stuff when parse starts.

also in doubt, is there a way to store these logs upon cloud vendors like google cloud storage?

I'm trying to run Parse Server on App Engine but in a non-flex env

would appreciate a lot some guidance

thanks

UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this issue Mar 21, 2020
…#6186)

* Fix parse-community#6179 Initializing default logger

Fixes: parse-community#6179

Removes unnessary logs

* fix typo

* if error just write to console
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants