我正在帮助一位朋友将 Parse 应用程序迁移到专用服务器而不是托管提供商,并且我在尝试解决我认为发生在服务器上的 Parse Server 实例中的错误时遇到了困难。
首先,这是来自 PM2 日志的错误堆栈,每次对服务器进行 GET 或 POST 时都会抛出该错误:
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)
由于我不太确定问题的性质(我查找了写入 EPIPE 错误是什么,但不确定为什么它会在 GET 上发生或为什么每次都会关闭),我只会提供我能想到的与此相关的每一条服务器信息。
这是目前的相对用户结构:
root -defuser:运行 mongo 实例以及 nginx -parse:通过 PM2 运行解析
这是 PM2 正在使用的 Ecosystem.json 文件:
{
"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:[email protected]:27017/beerdb?ssl=true",
"PARSE_SERVER_APPLICATION_ID": "super secret Parse key",
"PARSE_SERVER_MASTER_KEY" : " master key"
}
}]
}
这是 mongo.conf 文件:
# 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:
我认为 nginx 与此无关,但无论如何,这里是配置:
# 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;
}
}
我基本上没有主意了,尽管我并不是 Apache 设置方面的专家,所以这可能是一个愚蠢的疏忽或超出了我的理解范围。因此,如果有什么简单的问题,我将不胜感激。
答案1
重启服务器似乎可以解决问题。另外,你应该在https://github.com/parseplatform/parse-server。
编辑:更新至 parse-server v2.2.17 应该可以解决你的问题