Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Parse Server AWS guide #893

Open
wants to merge 3 commits into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
108 changes: 74 additions & 34 deletions _includes/parse-server/deploying-aws-ubuntu.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,14 @@ Check the install was ok, you should see the version installed.
node -v
```


Install [npm](https://www.npmjs.com)
```bash
sudo apt install npm
```



Install [yarn](https://yarnpkg.com)
```bash
sudo npm install yarn g
sudo npm install yarn -g
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is yarn required in this example? I don't see any yarn command being executed?

```

### Install PostgreSQL Server
Expand All @@ -62,89 +59,121 @@ sudo su postgres
psql
```

```bash
```sql
ALTER USER postgres password 'myStrongPassword';
```

Quit psql typing `\q`

Exit postgres user typing `exit`

Navigate to main folder inside postgresql/version/
Navigate to main folder inside `postgresql/version/`
```bash
cd /etc/postgresql/14/main/
```
We need to edit two files, `pg_hba.conf` and `postgresql.conf`
```bash
sudo nano pg_hba.conf
sudo nano -w pg_hba.conf
```
Scroll down the file and Add `host, all, all, 0.0.0.0/0, md5`, has to be the first line before `local, all, postgres, , peer`

| TYPE | DATABASE | USER | ADDRESS | METHOD |
| ---- | -------- | ---- | ------- | ------ |
| host | all | all | 0.0.0.0/0 | md5 |
| local | all | postgres | | peer |
{: .docs_table}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{: .docs_table}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not styling the tables appropriate? (I was planning to style the tables in all the docs, some docs already had that style, not sure when/who did it)
example of "table" (GH does format the table with borders, but the docs doesn't)
image

Copy link
Member

@mtrezza mtrezza Aug 6, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. What is the benefit of a table without borders? To me it seems less readable, especially in the example above where the alignment varies.


Close the file and save the changes with `Control+X` and `Y`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Close the file and save the changes with `Control+X` and `Y`
Close the file and save the changes with `Control`+`X` and `Y`


```bash
sudo nano postgresql.conf
sudo nano -w postgresql.conf
```
Search for `#listen_addresses='localhost'`, uncomment the line and replace `localhost` for `*`

Close the file and save the changes with `Control+X` and `Y`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Close the file and save the changes with `Control+X` and `Y`
Close the file and save the changes with `Control`+`X` and `Y`


Restart the PostgreSQL server
```bash
sudo service postgresql restart
```

### Setup Parse Server

Create a directory
```bash
cd ~
```
Create a folder called parse-server
```bash
mkdir parse-server
cd ~ && mkdir parse-server && cd parse-server
```

Install Parse Server Locally
```bash
cd parse-server
sudo yarn add parse-server
```

Run the bash script and follow the instructions, the script have some visual issues and the keys generation doesn't work.
```bash
sh <(curl -fsSL https://raw.githubusercontent.com/parse-community/parse-server/master/bootstrap.sh)
Comment on lines -112 to -114
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we abandoning the bash script?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It offers little or no functionality and I decided to install parse-server from npm in this guide (don't remember right now if the bootstrap installs the npm version or the node one..), some functionalities didn't work, and had some visuals faults, I was looking to refactor the bootstrap into a more dynamic one with more options, etc (I think using node installer or something like that, the same I saw in other products), but not sure If I have the knowledge to do it...

Edit the `package.json` file with your preferences, but do not change the start line inside the scripts.
```jsonc
Comment on lines +112 to +113
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Edit the `package.json` file with your preferences, but do not change the start line inside the scripts.
```jsonc
Edit the `package.json` file with your preferences, but do not change the start line inside the scripts.
```jsonc

{
"name": "my-app",
"description": "parse-server for my App",
"scripts": {
"start": "parse-server config.json"
},
"dependencies": {
"parse-server": "^5.2.1"
}
Comment on lines +115 to +122
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"name": "my-app",
"description": "parse-server for my App",
"scripts": {
"start": "parse-server config.json"
},
"dependencies": {
"parse-server": "^5.2.1"
}
"name": "my-app",
"description": "My amazing Parse Server app.",
"scripts": {
"start": "parse-server config.json"
},
"dependencies": {
"parse-server": "x.y.z" // Replace x.y.z with the latest stable version of Parse Server
}

}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

```
After that, we need to setup the configuration file, use your own `appId`, `masterKey` and `clientKey`, use random strings or some generator tool to create secured keys.
Close the file and save the changes with `Control+X` and `Y`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Close the file and save the changes with `Control+X` and `Y`
Close the file and save the changes with `Control+X` and `Y`


After that, we need to create a configuration file, use your own `appId`, `masterKey` and `clientKey`, use random strings or some generator tool to create secured keys.

```bash
sudo nano -w config.json
```
This are the basic options of the config.json file, for the full list you can type `parse-server --help` or refer to the [full options document](https://parseplatform.org/parse-server/api/5.2.0/ParseServerOptions.html) for more details.

```jsonc
{
"appId": "exampleAppId",
"masterKey": "exampleMasterKey",
"clientKey": "exampleClientKey",
"appName": "MyApp",
"cloud": "./cloud/main",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing the cloud code file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure/don't remember right now, probably because I saw somewhere? or because in this guide I didn't explain how to add the file... ?🤷‍♂️

"serverURL": "http://<IP_OR_DOMAIN>",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we just use "serverURL": "http://localhost", to simplify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guide is for AWS so I think it has to be linked to some real ip/domain, (but this guide should work in local linux distribution too... )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The serverURL is the local domain for the server to call itself. Localhost should usually work, unless in some special scenarios in which you want to distribute the load over a group of servers.

"mountPath": "/parse",
"publicServerURL": "http://<IP_OR_DOMAIN>",
"databaseURI": "postgres://postgres:myStrongPassword@localhost:5432/postgres"
}
```
Close the file and save the changes with `Control+X` and `Y`

This are the basic options of the `config.json` file, for the full list you can type `parse-server --help` or refer to the [full options document](https://parseplatform.org/parse-server/api/5.2.0/ParseServerOptions.html) for more details.

Install Parse Server globally

Start Parse Server using the script command in the package.json
```bash
sudo npm install -g parse-server
npm start
```

Start Parse Server using the script command in the config.json
Check if Parse Server is running typing `http://<IP_OR_DOMAIN>:1337` in your browser's address bar, you should see `{"error":"unauthorized"}`, that means the server is running.

To daemonized parse-server to keep it running and alive all the time, you can use the package [PM2](https://pm2.keymetrics.io).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
To daemonized parse-server to keep it running and alive all the time, you can use the package [PM2](https://pm2.keymetrics.io).
To daemonize Parse Server to keep it running and alive all the time, you can use the package [PM2](https://pm2.keymetrics.io).


Shutdown Parse Server pressing `Control+C`.

Check if PM2 is installed
```bash
npm list --depth 0 -g pm2
```
If the terminal shows `/usr/lib/(empty)`, means that PM2 is not installed, procced to install PM2 package globally
```bash
npm start
sudo npm install pm2 -g
```
or manually with the nohup command and specifying the configuration file, this option will keep the server running even if you close the terminal
Add Parse Server to PM2
```bash
pm2 start npm --name "parse-server" -- start
```
Save and syncronize this list
```bash
nohup parse-server config.json &
```
Check if Parse Server is running typing `http://<IP_OR_DOMAIN>:1337` in your browser's address bar, you should see `{"error":"unauthorized"}`
pm2 save
```

### Setup Parse Dashboard

Expand All @@ -157,7 +186,7 @@ Once installed, you need to configure Parse Dashboard, go to `/usr/lib/node_modu
```bash
sudo nano -w parse-dashboard-config.json
```
This is an example of parse-dashboard.config.json.
This is an example of `parse-dashboard.config.json`.
```jsonc
{
"apps": [{
Expand All @@ -178,10 +207,21 @@ Start Parse Dashboard
```bash
parse-dashboard
```
or with the nohup command and specifying the configuration file, this option will keep the dashboard running even if you close the terminal
```bash
nohup parse-dashboard --dev --config parse-dashboard-config.json &
```

Check if Parse Dashboard is running typing `http://<IP_OR_DOMAIN>:4040` in your browser's address bar, you should see the login form, use the `user` and `pass` that you set in the `parse-dashboard-config.json` file.

Shutdown Parse Dashboard pressing `Control+C`.

Add Parse Dashboard to the process manager PM2
```bash
pm2 start parse-dashboard
```
Save and syncronize PM2 list
```bash
pm2 save
```

Adding Parse Server and Parse Dashboard to PM2, will ensure that if the server restarts or reboot for some reason, this two apps will be relaunched automatically.
PM2 stores the logs in a subfolder called `logs` where the apps are. To sneak peek the logs you can run `pm2 logs` in the terminal.

Note: if you are using a secure certificate in your host, be sure to modify the urls related to your configuration in the examples above from `http` to `https`.
2 changes: 1 addition & 1 deletion assets/js/bundle.js

Large diffs are not rendered by default.