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
- Parse-Server
- Ubuntu
- 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 that 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, analytics, and scheduling and sending 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 is 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 the 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.
The steps provided for installing Node.js on a Debian-based system like Ubuntu or Debian are generally still considered best practice. However, there have been some updates and improvements. Here is an updated set of instructions for installing Node.js:
-
Update the system packages:
sudo apt updatesudo apt upgrade -
Install the required packages:
sudo apt install -y ca-certificates curl gnupg -
Add the NodeSource APT repository:
- Create the necessary directory:
sudo mkdir -p /etc/apt/keyrings
- Download and add the NodeSource GPG key:
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
- Add the NodeSource repository:
NODE_MAJOR=18echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
- Create the necessary directory:
-
Install Node.js:
sudo apt updatesudo apt install -y nodejs -
Verify the installation:
node -v
These steps should install Node.js efficiently on your system. Additionally, you might consider using NVM (Node Version Manager) for greater flexibility in managing multiple Node.js versions, especially in a development environment.
Which returns Node.js latest 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 server attributes:
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 the 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 the 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.