-
Notifications
You must be signed in to change notification settings - Fork 0
Portal
#Portal Portal relies on several things:
- Discourse needs to have embedding set up so that comments can show up
- Tessel Oauth is used for all of the sign in, so those have to be pointed properly.
Portal runs on Digital Ocean. The stack is:
- Nginx
- Portal
- Postgres
- Redis
-
Bring up a new DO box (512MB works)
-
Run the following
apt-get update; apt-get install nodejs nodejs-legacy npm nginx postgresql postgresql-contrib redis-server
The postgres
user can use psql
to access the postgres database. Launch the postgres console via
sudo -u postgres psql -U postgres
-
Set up Nginx
- make a config file for the app
vi /etc/nginx/sites-available/portal
upstream portal { server 127.0.0.1:3000; } server { listen 0.0.0.0:80; access_log /var/log/nginx/portal.log; # Make site accessible from http://localhost/ server_name portal.tessel.io; # swap out with server name location / { proxy_pass http://portal/; proxy_redirect off; } }
- symlink over to sites-enabled
ln -s /etc/nginx/sites-available/portal /etc/nginx/sites-enabled/portal
- restart nginx
sudo /etc/init.d/nginx restart
- make a config file for the app
-
Set up Redis. Default Redis port is 6379.
-
Set up backups
-
Make these directories
mkdir /opt/backups; mkdir /opt/scripts; mkdir /opt/logs;
-
put this
backup_postgres.sh
script in/opt/scripts
#!/bin/bash DATE=$(date +"%m-%d-%y") echo "Starting backup of $1 on $DATE" pg_dump -U postgres $1 > /opt/backups/$1-$DATE.sql
-
Set up a cronjob. The
backup_postgres
script can only be run as thepostgres
user and not root, so either switch to thepostgres
user or add backup to the postgres cronjob. Right now we're going to add it to the postgres cron job.
`su postgres; crontab -e;`
Now add the following
```
0 3 * * * /opt/scripts/backup_postgres.sh portal > /opt/logs/backup_postgres.log 2>&1
```
**TODO: UPLOAD TO S3**
*** make sure permissions are properly set on all files not accessed by root ***
-
Clone down the repo
cd /opt/apps; git clone https://github.com/tessel/portal.git
-
Fill out the config envs to
.env
or copy them over from another server -
Run the db migrations
- make the proper users/databases in postgres. switch to the postgres user
su postgres;' then
psql -U postgres` - Now alter the database:
create user portal; create database tesselportal owner portal; alter user portal with password 'testpw';
- exit out of
psql
and run the db migrations withmake migrate
.
- make the proper users/databases in postgres. switch to the postgres user
-
Set up Nginx, Postgres, Redis, and the node app to boot on startup. (I think that the nginx, postgres, and redis setup already covers this part)
-
Run the node app. Forever.
npm install -g forever
make a file called
/opt/scripts/start_app.sh
#!/bin/bash cd /opt/app/portal; forever start app.js;
Then add this to
/etc/rc.local
sh /opt/scripts/start_app.sh > /opt/logs/start_app.log 2>&1
Now hit the server and you should see portal.