There are a lot of manuals for migrating Parse servers to different platforms but none of them say which kind of plugins and packages are needed for those web applications which work with Expressjs on the cloud. Does anybody have any suggestions for this problem?
I went through the steps below on an Amazon AWS server with an Ubuntu instance. Everything is OK for API but not for the web app Expressjs.
node install
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs git
sudo apt-get update
sudo npm install -g parse-server pm2
sudo npm install -g express@3.1.0 underscore parse-express-https-redirect
sudo npm install -g parse-express-raw-body ejs@1.0.0 parse-express-cookie-session
At the second step, I tried to run parse-server with pm2 service of node as below:
Create pm2 server with Nodejs
sudo useradd --create-home --system parse
sudo passwd parse
USER_PASS
sudo su parse
cd ~
mkdir -p ~/cloud
cp -r /tmp/my-cloud-files /home/parse/
\__ cloud
\__ main.js
\__ app.js
\__ ...
\__ public
\__ config
nano 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": "/home/parse/cloud/main.js",
"PARSE_SERVER_DATABASE_URI": "mongodb://mongo_user:mongo_user_pass@localhost:27017/takimtakip",
"PARSE_SERVER_APPLICATION_ID": "application_id",
"PARSE_SERVER_MASTER_KEY": "application_master_key",
}
}]
}
export NODE_PATH= (echo $NODE_PATH):.
pm2 start ecosystem.json
pm2 list
But when I looked at the pm2 log file, I see the following
pm2 show parse-wrapper
┌───────────────────┬────────────────────────────────────────────────┐
│ status │ online │
│ name │ parse-wrapper │
│ restarts │ 72402 │
│ uptime │ 0s │
│ script path │ /usr/bin/parse-server │
│ script args │ N/A │
│ error log path │ /home/parse2/.pm2/logs/parse-wrapper-error.log │
│ out log path │ /home/parse2/.pm2/logs/parse-wrapper-out.log │
│ pid path │ /home/parse2/.pm2/pids/parse-wrapper.pid │
│ interpreter │ node │
│ interpreter args │ N/A │
│ script id │ 0 │
│ exec cwd │ /home/parse │
│ exec mode │ fork_mode │
│ node.js version │ 5.10.1 │
│ watch & reload │ ✘ │
│ unstable restarts │ 0 │
│ created at │ 2016-04-15T14:42:09.280Z │
└───────────────────┴────────────────────────────────────────────────┘
tail -f /home/parse2/.pm2/logs/parse-wrapper-error.log
TypeError: Cannot read property 'defaults' of undefined
at module.exports (/home/parse2/node_modules/parse-express-cookie-session/index.js:64:26)
at Object.<anonymous> (/home/parse2/cloud/app.js:25:9)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function._load (/usr/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/parse2/cloud/main.js:1:63)