MathML Cloud Server Admin

compared with
Current by Nirupa Kumar
on Mar 22, 2016 18:08.

Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (12)

View Page History

h1. URLs

* Live: [https://mathmlcloud.org]
* Staging: [https://staging.mathmlcloud.org]
* Live API: [https://mathmlcloud.org]
* Staging API: [https://staging.mathmlcloud.org]
** _The API URLs are the same as the app because we are bypassing the Azure API Management gateway for now since it has some unresolved issues._

{noformat}

To provision a server on Azure:

{noformat}
h1. Database changes

Sails will not do any database migrations when running as production. Sails.js, [http://sailsjs.org/#/documentation/concepts/Deployment], recommends using 1 of 2 approaches for database migrations:

{quote}
{quote}

Up to this point, all production database migrations for mathmlcloud.org have been performed by cloning the release branch, updating config/connections.js with the url to production's MongoLab database, and running sails lift in your local checkout's home directory, ex \~/boss/mathmlcloud-v5.1.5

h1. Deploy code to staging

Each of the repositories has a hook defined similarly:
* mmlc-app: [https://github.com/benetech/mmlc-app/settings/hooks/4418833#deliveries]
* mmlc-api: [https://github.com/benetech/mmlc-api/settings/hooks/3321880#deliveries]

The hook is implemented within the API in the api/controllers/GitHookController.js file.

* ssh to the server
* checkout the latest releases for the app and for the api. The api is installed at \~/mathml-cloud and the app is installed at \~/mathml-cloud/assets.
* install any new node packages
* restart the server

Starting the app as production will not perform any database migrations so they will have to be done locally (See Database changes above).

h1. Troubleshooting

Steps to follow if website is down :
* Try restarting from Azure
* Run command to check if process is running by:

{noformat}
ssh -l mmlc mathml-cloud.cloudapp.net -p 22
cd mathml-cloud
sudo pm2 list
{noformat}
Should see one process running. If not , need to restart server by running the following command :
{noformat}
sudo pm2 stop 0 # stop process 0, MMLC (precautionary)
sudo SECRET_TOKEN=${SECRET_TOKEN} \
MONGO_URL=$MONGO_URL \
NODE_ENV=$NODE_ENV \
SMTP_SASL_USER=$SMTP_SASL_USER \
SMTP_SASL_PASSWORD=$SMTP_SASL_PASSWORD \
pm2 start app.js # starts MMLC
{noformat}