The nohup
command allows you to manually start the Parse server. However, the downside of this procedure is that if the instance on which the Parse server is installed fails, the Parse server will not restart automatically.
Installing Parse Server on Ubuntu 20.04
- advanced
- settings
- Parse-Server
- Ubuntu-20.04
- MongoDB
Parse provides a cloud-based backend service to build data-driven mobile applications quickly. Initially developed by Facebook, Parse is a free and open-source Backend as-a-Service (BaaS) platform which can be deployed to any infrastructure that runs NodeJS. It can be added to existing web applications, or run by itself. Parse server comes with a simple and easy-to-use web interface that can be used for data manipulation, to view analytics, and to schedule and send push notifications.
Before you start
To complete the actions presented below, you must have:
- A Scaleway account logged into the console
- Owner status or IAM permissions allowing you to perform actions in the intended Organization
- An SSH key
- An Instance running on Ubuntu Focal Fossa or later
Installing MongoDB
MongoDB is a document-oriented database that is free and open-source. It considered one of the most popular NoSQL database engines because it is scalable, powerful, reliable and easy to use. In contrast to relational databases, MongoDB does not require a deep predefined schema before you can add data since it can be altered at any time.
- Update Ubuntu package manager.
apt update
- Upgrade the Ubuntu packages already installed.
apt upgrade
- Install MongoDB. By default, MongoDB is available in the Ubuntu 20.04 default repository.
apt install mongodb-server -y
- Verify MongoDB status.
systemctl status mongodb.service● mongodb.service - An object/document-oriented databaseLoaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)Active: active (running) since Tue 2020-11-03 15:43:50 UTC; 22s agoDocs: man:mongod(1)Main PID: 718 (mongod)Tasks: 23 (limit: 4915)Memory: 42.2MCGroup: /system.slice/mongodb.service└─718 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.confNov 03 15:43:50 scw-friendly-edison systemd[1]: Started An object/document-oriented database.
Installing Node.js
By default, Node.js is not available in the Ubuntu 20.04 default repository. Therefore Node.js needs to be added to the repository of your system. In addition, ensure curl
is installed on your system.
-
Add an external repository for the required version of Node.js. Make sure to replace
NODE_MAJOR
with the version number of the latest node runtime.apt updateapt install -y ca-certificates curl gnupgmkdir -p /etc/apt/keyringscurl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpgNODE_MAJOR=18echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list -
Install Node.js.
apt install nodejs -y -
Install yarn package manager.
npm install -g yarn -
Verify the Node.js version.
node --versionWhich returns Node.js lastest version:
v18.16.0
Installing Parse Server
-
Install the parse-server module using the Yarn package manager.
yarn global add parse-server...success Installed "parse-server@6.1.0" with binaries:- parse-server -
Create a Parse server configuration file and define the attributes of the parse server.
nano config.json -
Add the following lines:
{"appName": "Parse Server Application","databaseURI": "mongodb://localhost:27017/parsedb","appId": "SCWASRTWK9Y6AVMP3KFC","masterKey": "LASDK823JKHR87SDFJSDHF8DFHASFDF","serverURL": "https://localhost:1337/parse","publicServerURL": "https://0.0.0.0:1337/parse","port": 1337}The configuration details are as follows:
appName
: Set any name for your Parse serverdatabaseURI
: Connection string to the MongoDB databaseappID
: Set a random string as appID, which will be used to connect the server.masterKey
: Set a random string for the master key.serverURL
: Set a URL for your parse serverpublicServerURL
: Set a public URL for your parse serverport
: Indicate the server port
-
Save and close the file.
-
Start the Parse server.
Notenohup parse-server config.json & -
Run the following command to verify that the Parse server is listening on port 1337 (mentioned in the configuration file):
ss -ant | grep 1337LISTEN 0 511 0.0.0.0:1337 0.0.0.0:*
Turning Parse Server into a service with systemd
Creating a systemd service file allows you to automatically run and manage your application. It will restart in case of a failure (unexpected exit), and even survive server restarts.
-
Create a file called
parse.server.service
from/etc/systemd/system/
.nano parse.server.service -
Copy the following lines.
[Unit]Description=Parse Server serviceAfter=mongodb.serviceStartLimitIntervalSec=0[Service]Type=simpleRestart=alwaysRestartSec=1User=ubuntuExecStart=/usr/local/bin/parse-server /ubuntu/config.json[Install]WantedBy=multi-user.targetThe configuration details are as follows:
Description
: Define a name for your serviceAfter
: Define after which service the application startsUser
: Set your actual usernameExecStart
: Set the proper path to your script
-
Save and close the file.
-
Start the Parse server.
systemctl start parse.server.service -
Verify the status of the Parse server.
systemctl status parse.server.serviceWarning: The unit file, source configuration file or drop-ins of parse.server.service changed on disk. Run 'systemctl daemon-reload' to reload units.● parse.server.service - Parse Server serviceLoaded: loaded (/etc/systemd/system/parse.server.service; disabled; vendor preset: enabled)Active: active (running) since Tue 2020-11-10 12:28:20 UTC; 1h 13min agoMain PID: 18097 (node)Tasks: 11 (limit: 4915)Memory: 63.2MCGroup: /system.slice/parse.server.service└─18097 node /usr/local/bin/parse-server /root/config.json -
Get it to automatically start on boot.
systemctl enable parse.server.service
Configuring Parse Server dashboard
Parse server comes with a Dashboard for managing your Parse server applications. It is accessible through a web browser.
-
Install Parse dashboard.
yarn global add parse-dashboardsuccess Installed "parse-dashboard@2.1.0" with binaries:- parse-dashboard -
Create a configuration file for the Parse dashboard.
nano parse-dashboard-config.json -
Add the following lines. Do not forget to replace your server IP address.
{"apps": [{"serverURL": "http://your-server-ip:1337/parse","appId": "SCWASRTWK9Y6AVMP3KFC","masterKey": "LASDK823JKHR87SDFJSDHF8DFHASFDF","allowInsecureHTTP": "true","appName": "ParseApp"}],"users": [{"user":"scaler1","pass":"scalewayrocks"}],"iconsFolder": "icons"}The configuration details are as follows:
serverURL
: Set a URL for your parse serverappID
: Set a random string as appID, which will be used to connect the server.masterKey
: Set a random string for the master key.appName
: Set any name for your Parse serveruser
: Set the username to connect to the Parse Dashboardpass
: Set the password to connect to the Parse Dashboard
-
Save and close the file.
-
Start the Parse server Dashboard.
NoteThe
nohup
command allows you to manually start the Parse server. However, the downside of this procedure is that if the instance on which the Parse server is installed fails, the Parse server will not restart automatically.nohup parse-dashboard --dev --config parse-darshboard-config.json & -
Run the following command to verify that the Parse server Dashboard is listening on port 4040.
ss -ant | grep 4040LISTEN 0 511 0.0.0.0:4040 0.0.0.0:*
Turning Parse Server dashboard into a service with systemd
-
Create a file called
parse.server.dashboard.service
from/etc/systemd/system/
.nano parse.server.dashboard.service -
Copy the following lines:
[Unit]Description=Parse Server Dashboard serviceAfter=parse.server.serviceStartLimitIntervalSec=0[Service]Type=simpleRestart=alwaysRestartSec=1User=ubuntuExecStart=/usr/local/bin/parse-dashboard --dev --config /ubuntu/parse-dashboard-config.json[Install]WantedBy=multi-user.targetIn the example above, the
After
directive implies that the Parse server Dashboard service starts after the Parse server service itself. -
Start the Parse server Dashboard service.
systemctl start parse.server.dashboard.service -
Verify the status of the Parse server.
systemctl status parse.server.dashboard.serviceparse.server.dashboard.service - Parse Server Dashboard serviceLoaded: loaded (/etc/systemd/system/parse.server.dashboard.service; disabled; vendor preset: enabled)Active: active (running) since Tue 2020-11-10 12:39:56 UTC; 1h 17min agoMain PID: 18312 (node)Tasks: 11 (limit: 4915)Memory: 24.0MCGroup: /system.slice/parse.server.dashboard.service└─18312 node /usr/local/bin/parse-dashboard --dev --config /root/parse-darshboard-config.json
Accessing the Parse Server dashboard
- Access the Parse server dashboard by visiting the URL
http://your-server-ip:4040
- Add the credentials that you entered in the
parse-darshboard-config.json
file.