-
-
Notifications
You must be signed in to change notification settings - Fork 6
Production
How to deploy Saveto.co in production server.
-
Install
nginx
,pm2
sudo apt-get install -y nginx sudo npm i -g pm2
-
Start
PM2
instance.pm2 start app.js -i 2 -n 'saveto'
With: * -i 2: start Saveto with 2 instances cluster mode. When some instance down, web service still available in another one. Make your website has no downtime.
- -n 'saveto' instance name.
You will see:
[PM2] Starting app.js in cluster_mode (2 instances) [PM2] Done. ┌──────────┬────┬─────────┬──────┬────────┬─────────┬────────┬─────────────┬──────────┐ │ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │ ├──────────┼────┼─────────┼──────┼────────┼─────────┼────────┼─────────────┼──────────┤ │ quick │ 0 │ cluster │ 8362 │ online │ 0 │ 0s │ 18.047 MB │ disabled │ │ quick │ 1 │ cluster │ 8371 │ online │ 0 │ 0s │ 15.105 MB │ disabled │ └──────────┴────┴─────────┴──────┴────────┴─────────┴────────┴─────────────┴──────────┘
-
Config
Nginx
Open nginx config file/etc/nginx/sites-enabled/default
sudo nano /etc/nginx/sites-enabled/default
Update the config file with:
server { listen 80 default_server;[PM2][Module] Module downloaded
[PM2] Process launched
[PM2][Module] Module successfully installed and launched
[PM2][Module] : To configure module do
[PM2][Module] : $ pm2 conf
┌──────────┬────┬─────────┬──────┬────────┬─────────┬────────┬──────────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
├──────────┼────┼─────────┼──────┼────────┼─────────┼────────┼──────────────┼──────────┤
│ quick │ 0 │ cluster │ 8362 │ online │ 0 │ 12m │ 110.535 MB │ disabled │
│ quick │ 1 │ cluster │ 8371 │ online │ 0 │ 12m │ 111.191 MB │ disabled │
└──────────┴────┴─────────┴──────┴────────┴─────────┴────────┴──────────────┴──────────┘
Module activated
┌───────────────┬─────────┬────────────┬────────┬─────────┬─────┬─────────────┐
│ Module │ version │ target PID │ status │ restart │ cpu │ memory │
├───────────────┼─────────┼────────────┼────────┼─────────┼─────┼─────────────┤
│ pm2-auto-pull │ N/A │ 9360 │ online │ 0 │ 25% │ 12.586 MB │
└───────────────┴─────────┴────────────┴────────┴─────────┴─────┴─────────────┘
Use pm2 show <id|name>
to get more details about an app
listen [::]:80 default_server ipv6only=on;
# Make site accessible from http://localhost/
# server_name localhost;
location / {
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:6969;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
...
Save file in nano with `Ctrl + C` and press `Y`
Restart nginx:
```sh
sudo service nginx restart
- Fire: http://saveto.co
pm2 install pm2-auto-pull
[PM2][Module] Module downloaded
[PM2] Process launched
[PM2][Module] Module successfully installed and launched
[PM2][Module] : To configure module do
[PM2][Module] : $ pm2 conf <key> <value>
┌──────────┬────┬─────────┬──────┬────────┬─────────┬────────┬──────────────┬──────────┐
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
├──────────┼────┼─────────┼──────┼────────┼─────────┼────────┼──────────────┼──────────┤
│ quick │ 0 │ cluster │ 8362 │ online │ 0 │ 12m │ 110.535 MB │ disabled │
│ quick │ 1 │ cluster │ 8371 │ online │ 0 │ 12m │ 111.191 MB │ disabled │
└──────────┴────┴─────────┴──────┴────────┴─────────┴────────┴──────────────┴──────────┘
Module activated
┌───────────────┬─────────┬────────────┬────────┬─────────┬─────┬─────────────┐
│ Module │ version │ target PID │ status │ restart │ cpu │ memory │
├───────────────┼─────────┼────────────┼────────┼─────────┼─────┼─────────────┤
│ pm2-auto-pull │ N/A │ 9360 │ online │ 0 │ 25% │ 12.586 MB │
└───────────────┴─────────┴────────────┴────────┴─────────┴─────┴─────────────┘
Use `pm2 show <id|name>` to get more details about an app
See https://github.com/duyetdev/server-dropbox-backup-schedule
pm2 startup [platform] # [platform] = ubuntu, centos, redhat, gentoo, systemd, darwin, amazon