问题
I'm helping a friend with migrating a Parse app to a dedicated server as opposed to a hosting provider, and I've gotten stuck trying to resolve an error that I THINK is happening in the Parse Server instance on the server.
Firstly, here is the error stack from the PM2 logs, it gets thrown every time a GET or POST is made to the server:
parse-wrapper-0 (err): at null.<anonymous> (/usr/lib/node_modules /parse-server/node_modules/mongodb-core/lib/connection/pool.js:119:12)
parse-wrapper-0 (err): at g (events.js:273:16)
parse-wrapper-0 (err): at emitTwo (events.js:100:13)
parse-wrapper-0 (err): at emit (events.js:185:7)
parse-wrapper-0 (err): at Socket.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/connection/connection.js:144:49)
parse-wrapper-0 (err): at Socket.g (events.js:273:16)
parse-wrapper-0 (err): at emitOne (events.js:90:13)
parse-wrapper-0 (err): error: Uncaught internal server error. { [MongoError: server localhost:27017 received an error {"name":"MongoError","message":"write EPIPE"}]
parse-wrapper-0 (err): name: 'MongoError',
parse-wrapper-0 (err): message: 'server localhost:27017 received an error {"name":"MongoError","message":"write EPIPE"}' } MongoError: server localhost:27017 received an error {"name":"MongoError","message":"write EPIPE"}
parse-wrapper-0 (err): at null.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/topologies/server.js:308:40)
parse-wrapper-0 (err): at emitTwo (events.js:100:13)
parse-wrapper-0 (err): at emit (events.js:185:7)
parse-wrapper-0 (err): at null.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/connection/pool.js:119:12)
parse-wrapper-0 (err): at g (events.js:273:16)
parse-wrapper-0 (err): at emitTwo (events.js:100:13)
parse-wrapper-0 (err): at emit (events.js:185:7)
parse-wrapper-0 (err): at Socket.<anonymous> (/usr/lib/node_modules/parse-server/node_modules/mongodb-core/lib/connection/connection.js:144:49)
parse-wrapper-0 (err): at Socket.g (events.js:273:16)
parse-wrapper-0 (err): at emitOne (events.js:90:13)
Since I'm not really sure as to the nature of the problem (I looked up what the write EPIPE error is, but not sure as to why it's happening on GETs or why it's closing every single time), I'm just gonna give every piece of information about the server I can think of that is relevant to this.
This is the relative user structure right now:
root -defuser: running the mongo instance as well as nginx -parse: running parse via PM2
Here is the ecosystem.json file PM2 is using:
{
"apps":[{
"name" : "parse-wrapper",
"script" : "/usr/bin/parse-server",
"watch" : true,
"merge_logs" : true,
"cwd" : "/home/parse",
"env" : {
"PARSE_SERVER_CLOUD_CODE_MAIN": "cloud/main.js",
"PARSE_SERVER_DATABASEURI": "mongodb://parse:SUPERPASSWORDHERE@domain.here:27017/beerdb?ssl=true",
"PARSE_SERVER_APPLICATION_ID": "super secret Parse key",
"PARSE_SERVER_MASTER_KEY" : " master key"
}
}]
}
Here's the mongo.conf file:
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
journal:
enabled: true
# engine:
# mmapv1:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
bindIp: 0.0.0.0
ssl:
mode: requireSSL
PEMKeyFile: /etc/ssl/mongo.pem
#processManagement:
security:
authorization: enabled
#operationProfiling:
#replication:
#sharding:
setParameter:
failIndexKeyTooLong: false
## Enterprise-Only Options:
#auditLog:
#snmp:
I don't think nginx has anything to do with this, but here's the config regardless:
# HTTP - redirect all requests to HTTPS
server {
listen 80;
listen [::]:80 default_server ipv6only=on;
return 301 https://$host$request_uri;
}
# HTTPS - serve HTML from /usr/share/nginx/html, proxy requests to /parse/
# through to Parse Server
server {
listen 443;
server_name domain.here;
root /usr/share/nginx/html;
index index.html index.htm;
ssl on;
# Use certificate and key provided by Let's Encrypt:
ssl_certificate /etc/letsencrypt/live/domain.here/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/domain.here/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
# Pass requests for /parse/ to Parse Server instance at localhost:1337
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:1337/parse/;
proxy_ssl_session_reuse off;
proxy_set_header Host $http_host;
proxy_redirect off;
}
}
I'm basically out of ideas here, although I'm not exactly an expert at much more than just setting up Apache, so it might be a stupid oversight or over my head. So, any assistance is appreciated and sorry if it is something simple.
回答1:
I met the same issue with my deployment. It turned out that Parse Dashboard made a lot of connections to MongoDB (> 1k connections in my case) so we have to increase the maximum connection limit in mongo.conf
and file descriptor limit (depends on your OS).
For example, in Linux:
- Edit the
mongo.conf
file and addmaxConns = 10000
- Edit the
/etc/sysctl.conf
file and addfs.file-max = 10000
- Running
ulimit -n 50000
来源:https://stackoverflow.com/questions/36852689/mongoerror-write-epipe-in-parse-server-installation