Skip to content

Commit

Permalink
Merge branch 'master' into db-script-cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
iamigo committed Nov 15, 2016
2 parents d380d7c + c0acc0e commit 085d071
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 76 deletions.
79 changes: 4 additions & 75 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ Refocus is a platform for visualizing the health and status of systems and/or se


- [Features](#features)
- [Installation](#installation)
- [Updates](#updates)
- [Development](#development)
- [Package Scripts](#package-scripts)
- [Usage](#usage)
- [How redis is used](#how-redis-is-used)
- [Running on Heroku](#running-on-heroku)
- [Troubleshooting a Heroku deployment](#troubleshooting-a-heroku-deployment)
- [Quickstart](#Quickstart)
- [Perspective Debugging](#perspective-debugging)
- [API Documentation](#api-documentation)
- [Securing Refocus](#securing-refocus)
Expand All @@ -40,73 +33,9 @@ Refocus is a platform for visualizing the health and status of systems and/or se
- Self-service
- Easy deployment to Heroku

## Installation
1. Install [Node.js](https://nodejs.org/).
1. Install [PostgreSQL](http://www.enterprisedb.com/products-services-training/pgdownload). Be sure to read the "PostgreSQL One Click Installer README" and follow the instructions there to adjust your shared memory as needed.
1. Install [Redis](http://redis.io/download).
1. Clone this git repository.
1. Run `cd refocus`.
1. Create a new branch: ```git checkout -b <your branch name> master```
1. Run `npm install`. This downloads and installs project dependencies and executes the post-install steps. Note: don't run this with sudo! You may get some weird errors later.
1. Install lunchy (`brew install Caskroom/cask/lunchy`). This will help you start redis.
1. Run `lunchy start redis` to start redis.
1. Run `npm start` to start your Node.js server at http://localhost:3000.
1. If you want to unload some of the processing to a background process run `npm run start-clock`. If you intend to deploy this on heroku and have heroku toolbelt installed run `heroku local` to start both the web and the background process.

### Updates
Whenever you pull down a new version of Refocus from the git repository:

1. Run `npm update` to make sure you have all the latest dependencies.
1. Run `npm start` to start your Node.js server at http://localhost:3000.

## Development
- Run `npm run build` and modify the webpack.config.js to take advantage of react hot module reload (react-hmr), for faster front-end development.
- At times the generated pages don't show due to this error in the browser console: `locals[0] does not appear to be a 'module' object with Hot Module replacement API enabled`. This can happen when the NODE_ENV is blank. To fix the issue, set the NODE_ENV to a non-empty value, then run the build again.
- If you want any of the packages to send output to stdout, you can start your server with `DEBUG=* node .` or you can spell out which packages you want to show debug output, e.g. `DEBUG=express*,swagger* node .`.
- Use [nodemon](http://nodemon.io/) to monitor for any changes in your source and automatically restart your server.
- Use Node.js [Debugger](https://nodejs.org/api/debugger.html).
- If you are making changes to the code, check for adherence to style guidelines by running `gulp style`.
- If you are making any changes to the DB schema, create a migration using `node_modules/.bin/sequelize migration:create --name example-name`

### Package Scripts
Execute any of the scripts in the `scripts` section of [`./package.json`](./package.json) by calling `npm run [SCRIPTNAME]`, e.g. `npm run test` or `npm run lint` or `npm run start`.

## Usage

> TODO
## How redis is used
On node server startup, two redis clients are instantiated:
The ```publisher``` is called by the sequelize ORM when a subject or sample is inserted/updated/deleted. It publishes a serialized object keyed by the record type (i.e. ```subject``` or ```sample```) and containing the object which was inserted/updated/deleted.
The ```subscriber``` parses the message string into an object then uses socket.io to broadcast the changes out to any connected browser clients.
After installing the server, you can run ```redis-cli``` to issue commands to redis server. Command to show active channels is: ```PUBSUB CHANNELS *```

## Running on Heroku
- Setup Heroku account and toolbelt (follow this guide https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction)
- Run ```heroku create``` to create Heroku project
- If you are not in a private space run ```PGSSLMODE=require``` to make all db data go over ssl
- Run ```heroku config:set NODE_ENV=test```
- Run ```heroku addons:create heroku-postgresql:hobby-dev``` to create a dev db
- Run ```git push heroku <your branch>:master``` which will push to Heroku and start up a dyno.
- Run ```heroku open``` and view the app running in Heroku
- Run ```heroku run bash``` then run ```mocha``` to execute the test suite
- If you are running the app in more than one dyno, you will need to force the client to communicate with the server only using websockets. To do so, set the config variable SOCKETIO_TRANSPORT_PROTOCOL to websocket or run ```heroku config:set SOCKETIO_TRANSPORT_PROTOCOL=websocket```
If you are running on Heroku and you want to use Google Analytics, store your tracking id in a Heroku config variable called `GOOGLE_ANALYTICS_ID`.

### Troubleshooting a Heroku deployment
- Log errors in suspected areas. Use the logging in the error handler
- For errors 'Relation __ does not exist', the db is not set up properly. Try resetting the database. Run ```heroku run bash``` to enter shell script mode, then run ```npm run checkdb```.
- Run ```heroku restart```, to restart the app
- Run ```heroku logs --tail``` to see the heroku logs, as they update

## Setup Production Environment on Localhost
If not already setup, follow Installation instructions to setup Refocus. Execute the following commands to setup production environment and corresponding config variables:

```
export NODE_ENV=production
export DATABASE_URL='postgres://postgres:postgres@localhost:5432/focusdb'
npm start
```
## Quickstart

See the [Quickstart](https://salesforce.github.io/refocus/docs/01-quickstart.html) guide to get going with Refocus!

## Securing Refocus
1. After installation, log in (UI or API) as `admin@refocus.admin` with password `password` and change the password for that account.
Expand Down
18 changes: 18 additions & 0 deletions docs/docs/03-quickstartheroku.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,21 @@ title: Quick Start Heroku
# Get up and running in seconds on Heroku.
[<img src="https://www.herokucdn.com/deploy/button.svg">](https://heroku.com/deploy?template=https://github.com/Salesforce/refocus)

## Running on Heroku
For the default setup you can click the heroku button to get Refocus running! If you want more control over your deployment than follow the steps below.
- Setup Heroku account and toolbelt (follow this guide https://devcenter.heroku.com/articles/getting-started-with-nodejs#introduction)
- Run ```heroku create``` to create Heroku project
- If you are not in a private space run ```PGSSLMODE=require``` to make all db data go over ssl
- Run ```heroku config:set NODE_ENV=test```
- Run ```heroku addons:create heroku-postgresql:hobby-dev``` to create a dev db
- Run ```git push heroku <your branch>:master``` which will push to Heroku and start up a dyno.
- Run ```heroku open``` and view the app running in Heroku
- Run ```heroku run bash``` then run ```mocha``` to execute the test suite
- If you are running the app in more than one dyno, you will need to force the client to communicate with the server only using websockets. To do so, set the config variable `SOCKETIO_TRANSPORT_PROTOCOL` to `websocket` (or if you prefer to use the command line, run ```heroku config:set SOCKETIO_TRANSPORT_PROTOCOL=websocket```).
- If you are running on Heroku and you want to use Google Analytics, store your tracking id in a Heroku config variable called `GOOGLE_ANALYTICS_ID`.

### Troubleshooting a Heroku deployment
- Log errors in suspected areas. Use the logging in the error handler
- For errors 'Relation __ does not exist', the db is not set up properly. Try resetting the database. Run ```heroku run bash``` to enter shell script mode, then run ```gulp resetdb```, to reset the db
- Run ```heroku restart```, to restart the app
- Run ```heroku logs --tail``` to see the heroku logs as they update
35 changes: 34 additions & 1 deletion docs/docs/04-quickstartlocal.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,40 @@ title: Quick Start Local
---

# QuickStart with Local Deployment
# Installation
1. Install [Node.js](https://nodejs.org/).
1. Install [PostgreSQL](http://www.enterprisedb.com/products-services-training/pgdownload). Be sure to read the "PostgreSQL One Click Installer README" and follow the instructions there to adjust your shared memory as needed.
1. Install [Redis](http://redis.io/download).
1. Clone this git repository.
1. Run `cd refocus`.
1. Create a new branch: ```git checkout -b <your branch name> master```
1. Run `npm install`. This downloads and installs project dependencies and executes the post-install steps. Note: don't run this with sudo! You may get some weird errors later.
1. Install lunchy (`brew install Caskroom/cask/lunchy`). This will help you start redis.
1. Run `lunchy start redis` to start redis.
1. Run `npm start` to start your Node.js server at http://localhost:3000.
1. If you want to unload some of the processing to a background process run `npm run start-clock`. If you intend to deploy this on heroku and have heroku toolbelt installed run `heroku local` to start both the web and the background process.

### Updates
Whenever you pull down a new version of Refocus from the git repository:

1. Run `npm update` to make sure you have all the latest dependencies.
1. Run `npm start` to start your Node.js server at http://localhost:3000.

[back to QuickStart Guide](./QuickStart.md)
## Setup Production Environment on Localhost
If not already setup, follow Installation instructions to setup Refocus. Execute the following commands to setup production environment and corresponding config variables:

```
export NODE_ENV=production
export DATABASE_URL='postgres://postgres:postgres@localhost:5432/focusdb'
npm start
```

## Usage

> TODO
## How redis is used
On node server startup, two redis clients are instantiated:
The ```publisher``` is called by the sequelize ORM when a subject or sample is inserted/updated/deleted. It publishes a serialized object keyed by the record type (i.e. ```subject``` or ```sample```) and containing the object which was inserted/updated/deleted.
The ```subscriber``` parses the message string into an object then uses socket.io to broadcast the changes out to any connected browser clients.
After installing the server, you can run ```redis-cli``` to issue commands to redis server. Command to show active channels is: ```PUBSUB CHANNELS *```
18 changes: 18 additions & 0 deletions docs/docs/40-coredevelopment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
layout: docs
title: Core Development
---

<h1>Core Development Work In Progress</h1>

## Development
- Run `npm run build` and modify the webpack.config.js to take advantage of react hot module reload (react-hmr), for faster front-end development.
- At times the generated pages don't show due to this error in the browser console: `locals[0] does not appear to be a 'module' object with Hot Module replacement API enabled`. This can happen when the NODE_ENV is blank. To fix the issue, set the NODE_ENV to a non-empty value, then run the build again.
- If you want any of the packages to send output to stdout, you can start your server with `DEBUG=* node .` or you can spell out which packages you want to show debug output, e.g. `DEBUG=express*,swagger* node .`.
- Use [nodemon](http://nodemon.io/) to monitor for any changes in your source and automatically restart your server.
- Use Node.js [Debugger](https://nodejs.org/api/debugger.html).
- If you are making changes to the code, check for adherence to style guidelines by running `gulp style`.
- If you are making any changes to the DB schema, create a migration using `node_modules/.bin/sequelize migration:create --name example-name`

### Package Scripts
Execute any of the scripts in the `scripts` section of [`./package.json`](./package.json) by calling `npm run [SCRIPTNAME]`, e.g. `npm run test` or `npm run lint` or `npm run start`.
2 changes: 2 additions & 0 deletions docs/docs/50-lensdevelopment.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ title: Lens Development
---

<h1>Lens Development</h1>

#[Refocus Lens Developer Kit Repo](https://github.com/Salesforce/refocus-ldk)

0 comments on commit 085d071

Please sign in to comment.