Files
PetitTetonMeteor/README.md

89 lines
6.0 KiB
Markdown

# Petit Teton Data Management Application (PTApp)
This application is designed to track sales and production data.
In a development environment, the application will create the database if it doesn't exist, naming it "meteor" and will run the database on localhost:3001. The application's web interface will be accessible on localhost:3000.
These can be changed in development mode by setting environment variables.
At runtime (production environment), the application should be deployed on a linux machine.
Package this application by running 'npm run build' from the command line in the project base directory, or double click the npm "build" script in the development environment.
1. Install MongoDB on the linux machine.
1. `sudo apt-get update`
1. `sudo apt-get install -y mongodb` (installs 2.6.10 on Ubuntu LTS 16.04 - that is the minimum version of mongo required for Meteor 1.4 - you should install the latest mongo: 3.2 per the meteor install instructions)
**OR**
See [instructions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/) for installing newer versions of MongoDB (RECOMMENDED)
1. Get the version of the mongo command line tool: `sudo mongo --version`
1. Get the version of the mongo server: `sudo mongod --version`
1. Start/stop/restart the mongo service: `sudo service mongod stop/start/restart`
1. View logs: `/var/log/mongodb/mongod.log`
1. Edit config: `/etc/mongod.conf` (see [docs](https://docs.mongodb.com/manual/reference/configuration-options/))
1. Run tools: (see [descriptions](https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/#packages))
- mongod (the mongo database server)
- mongo (command line shell for interacting with a running db)
- mongoimport (imports data from: Extended JSON, CSV, or TSV formats created by mongoexport or 3rd party tools)
- bsondump (converts bson file formats [binary] into human readable formats [JSON] - use with mongodump files)
- mongodump (produces binary output for backups - not for use with shared clusters and replica sets)
- mongoexport (produces JSON or CSV data)
- mongofiles (command line gridfs integration - for manipulating files)
- mongooplog (replication & polling - ?)
- mongoperf
- mongorestore
- mongostat
- mongotop (stats)
1. Install nodejs & npm
1. `sudo apt-get install nodejs`
1. `sudo apt-get install npm`
1. Install n
1. `sudo npm install -g n`
1. Update nodejs to 4.7.0 (for use with meteor 1.4 - may be another nodejs version for newer meteor versions): `n bin 4.7.0` (may need to first download 4.7.0 - see other docs on linux & nodejs)
1. `sudo n 4.7.0`
1. `sudo npm install -g npm` (updates npm?)
1. Install nginx on the linux machine.
1. Install samba on the linux machine. (`sudo nano /etc/samba/smb.conf` & `sudo service smbd restart`)
1. Share the /var/www directory using the www-data user.
1. Share the /etc/nginx directory using the root user (optional & security risk - makes configuring /etc/nginx/sites-available easier).
1. Share the nginx logs directory /var/logs/nginx using a standard user with read only access (maybe www-data?).
1. Install passenger which will glue the nginx web server to one or more instances of nodejs/meteor running on the machine. (See passenger site for updated install instructions - these are specific to Ubuntu)
1. `sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7`
1. `sudo apt-get install -y apt-transport-https ca-certificates`
1. `sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'`
1. `sudo apt-get update`
1. `sudo apt-get install -y nginx-extras passenger`
1. Configure the nginx sites-available file ("PTapp") to link nginx to passenger, and provide passenger the settings to startup meteor. Example: (replace {{xxxx}} with your own content) (NOTE: setting the mail_url fails, I used a release.properties file in the app's private directory instead, with code to use the properties file first in the server.js file in meteor.)
```
server {
listen 80;
listen [::]:80;
server_name app.petitteton.com;
root /var/www/PTApp/bundle/public;
# Turn on Passenger
passenger_enabled on;
# Tell Passenger that your app is a Meteor app
passenger_app_type node;
passenger_startup_file main.js;
# Tell your app where MongoDB is
passenger_env_var MONGO_URL {{your mongodb address/port/dbname. Example: mongodb://localhost:27017/PTApp}};
# Tell your app what its root URL is
passenger_env_var ROOT_URL http://app.petitteton.com;
#passenger_env_var MAIL_URL smtp://{{your email. example: administrator%40declarativeengineering.com}}:{{smtp password here - don't use symbols like # or $ etc}}@{{your email server. Example: secure.emailsrvr.com}};
passenger_nodejs /usr/local/n/versions/node/4.7.0/bin/node;
}
```
1. Restart nginx: `sudo service nginx restart`
1. Get status with `sudo passenger-status`
1. Stop passenger & nginx: `sudo service nginx stop` (use start or restart or reload also)
1. Create an app folder in /var/www (example: PTApp)
1. Unpack the packaged application into this new folder (easily done via the samba share on the windows development machine by drag and dropping the contents of the archive created in step 1).
1. Install the app with npm (navigate to /var/www/PTApp/bundle/programs/server): `npm install --production`
1. **Restart the passenger app each time the application is updated**: `sudo passenger-config restart-app /var/www/PTApp`
1. Use RDP to connect to the GUI for the linux server
1. Install Mongo Chef (free version) to connect to the db on localhost:27017
1. Download the archive.
1. Move the unpacked archive into /opt
1. Modify the ~/.bashrc to include: `PATH=$PATH:/opt/mongochef-3.5.0-linux-x86-dist/bin` at the end (not sure if this is necessary).
1. Run Mongo Chef from the GUI environment (how? - probably use the start menu -> Run, then pass the path like above + the executable name)
NOTE: Use MongoBooster on a windows development machine to connect to the dev database (localhost:3001) and to export.