Parse was a great initiative. Sadly it went down. It was a fantastic solution for those who want to quickly get their app done and backend was just a breeze. Things changed. However, not all is lost. Parse became open source. The source for Server and Dashboard are both out in the open. I had a mobile app that used Parse heavily . Parse shutdown was really hard for me. I went through all the alternatives but none got me more interested than actually running the infrastructure on my own dedicated linux server.

This blog points out various reference which helped along the way, various setbacks(which became experience) and tips that will help you guide through.

The end result, I moved everything to my hosted parse server and the app works just as it did before. Rest assure, its pretty easy.

Prerequisites (My way)

  1. DigitalOcean 10$ instance

    • DigitalOcean provides linux instance with various configuration. They have sensible defaults and extremely easy way of setting up server or remote VPS. Moreover, the documentation, they are detailed and covers the whole spectrum of things you want/wish/need to do.

    • I was a AWS user. Their humungous options drove me nuts to find the right thing(Paradox of Choice). Plus, after 1 free year, it costs a lot.

  2. Be able to ssh into remote machine via terminal

  3. Install nodejs. This will install npm with it.

    • To install Nodejs
    • Nodejs is a javascript runtime. It uses V8 Javascript engine and adds server specific features via C++ and are exposed to JS. V8 is open source and used in Chrome and Chromium browser.
  4. Install Mongodb: NoSQL database which Parse Server prefers.

    • Here is the installation guide
    • Its very important to not use mongodb-runner npm package that Parse-Server example uses. This particular package contains bunch of script to automate mongodb installation and running with a single command. The downside is your database will be purged if the mongodb-runner is terminated or restarted. This could happen for many reasons even in server environment.
  5. Lets now get Parse-Sever

    $ npm install -g parse-server
    
    • This command is all you need to get and install parse-server.
    • dont install mongodb-runner. Mongodb-runner is for 1 time testing only.
  6. If you want easy way to get started then, cloning this parse-server-example is a valid option. Check the details in the Readme.

    • This is how I got my first parse server working in a maintainable way.
    • If you clone this repo, this will download parse-server as a dependency; if not found or installed previously.
    • Modify your index.js file to customize. Refer to the Readme if its little confusing. Don’t panic, if you are afraid of javascript. We wont need much of it. Just some variable assignment.
  7. Okay we have almost done everything besides 2 things.

    • We don’t have dashboard so we cant see/edit/add new data to the backend.
    • We will do both in the next section. Now take a drink and lets get going.

Intermediate Server work

Apache is a well known Web Server but we will be using NGINX on this particular case. You could go with Apache but I prefer NGINX as it is more memory effecient (at least thats what I heard) and has nice configurations for us.

  1. Install and configure NGINX as described in this article.
  2. Open up port 4040 if you want to view the dashboard served from the server. If you want the dashboard to be client side then thats totally fine.
    • $ sudo ufw allow 4040/tcp
  3. Install parse-dashboard.

    • I prefer dashboard be in server. The reasons are 2. First, I can access server from any machine on the go. Second, it just a website interface to the parse-server. I would rather expose parse-dashboard than parse-server to the outside world.
    • install via
    $npm install -g parse-dashboard
    
    • Official parse-dashboard github repo
    • Readme on the repo should help you get using the dashboard.
    • I prefer to have a index.js file with all the configuration wrapped in express app. This is more flexible than tedious command line options argument and json config based setup.
    • Again, Read the readme very carefully. It helps a lot. It saves lots of googling for some minor things. Its all there. Waiting to be read. I thought I read all then, after some days, I kept googling how to pass 1 argument. Its not fun. Read the README.
  4. Now, if you have followed through step by step. You should be able to run parse-dashboard on port 4040. Remember we allowed 4040 to be reached from outside. Its time to check your dashboard.

    • From anywhere outside the server, browse to <your-server-ip>:4040
    • You should be able to see the dashboard with the parse-server app we created in the first place.
    • Get inside and add some data.
    • Notice, there is a section for CloudCode, Push, WebHooks and Logs. Exactly, the open source community have grown to implement almost all that was in Parse.com
  5. Now lets make our life simpler.

Intermediate II Server Work

Lets assume, your Parse-Server is working fine. What if at somepoint in time, the system crashes due to many requests (usually a good sign to indicate your customer base has grown) or any other reason. What if parse-server crashes? Will you log in and restart yourself? I don’t think so.

Enter pm2. A easy way to manage process. We will use pm2 to restart parse-server if the existing instance crashes automatically. This will also make sure parse-server is started on system reboot. Nice!!

  1. Install PM2

    $sudo npm install -g pm2
    
    • To make this pm2 package start on reboot or crash, you need to configure Systemd or Service. Look at PM2 section on this exhustive article
    • Start the parse server using $pm2 start <your-Parse-app-ServerPath>/index.js --name <yourappname>
    • Start the parse dashboard using $pm2 start <dashboardPath>/index.js --name <dashboardName>
    • Now you should be able to see the running process via $pm2 list
    • To see logs for specific process, you can use $pm2 logs <either app name or process id assigned by pm2>. This will be helpful in debugging certain queries and cloud code or in general what the server is doing.

    PM2 list

  2. If you want to associate this IP to a domain name.

  3. Daily MongoDB backup. Yes, you might need to protect your data after all.

    • Either choose to take snapshot every day and pay digitalocean some small amount.
    • Or, use cronjob to backup every day.
    • Backing up existing database is easy.
      • $mongodump
    • Restoring dumped data into database is easy too.
      • $mongorestore <dumpfile>
    • This article will walk through making daily backups
  4. Thats all. The rest will fall into place.

Hope you could manage to code your big app using a simple Parse backend.

As always, you can contribute to make this article more accurate or extend openly via Github repo

Thanks for Contribution

  1. Ahmed Rashad Basuony

Cheers!