我正在使用PM2运行parse-server 2.3.8,我正在尝试使用PM2运行具有相同解析实例的LiveQueryServer。下面是我的ecosystem.json中env的片段,它不起作用。
"env": {
...,
"PARSE_SERVER_LIVE_QUERY_OPTIONS": {
"classNames": ["MyClass", "MyOtherClass"],
"appId": "myAppId",
"masterKey": "myMasterKey",
"serverURL": "https:://mydomain.com/parse"
},
}
接下来,我创建了一个index.js并尝试将LiveQueryServer作为独立运行,但也无效。这是index.js的内容:
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var app = express();
var mount = 'parse';
var port = 1337;
var httpServer = require('http').createServer(app);
httpServer.listen(port);
ParseServer.createLiveQueryServer(httpServer, {
'appId': 'myAppID',
'serverURL': 'http:localhost:' + port + '/' + mount,
'logLevel': 'VERBOSE'
});
这是我根据Parse文档中链接的nginx tutorial配置nginx以允许websockets所添加的内容。
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server localhost:1337;
}
server {
listen 443;
location /parse {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
}