Skip to content

Commit

Permalink
[FEATURE] add setup and deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkady Fukzon committed Jan 20, 2016
1 parent 3ded71f commit 4941688
Show file tree
Hide file tree
Showing 8 changed files with 384 additions and 143 deletions.
79 changes: 23 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,23 @@
An application allowing to monitor the state of servers and requests of different kinds (pullrequests, graylogs).

<h2>Prerequisites:</h2>


* NodeJS and npm
* MongoDB
* Google Account and App with Google+ API enabled

<h2>Setup and Local Use:</h2>

* Create a google app with Google+ API enabled in the google developers console, and prepare the: Client ID, Secret and Callback Url
* Run: "npm install"
* Run: "node setup" and enter the requested parameters
* Add this line to your hosts file: 127.0.0.1 devflow.yourdomain.com # devflow
* Run with "npm start"
* Enter: localhost:3000 or http://devflow.yourdomain.com:3000/

( Please Run "npm install" again whenever changing node packages,
In order to debug it's possible to run "node debug app.js" - node's built-in debugger )

<h2>Optional Services Integration:</h2>

* GitHub
Expand All @@ -21,70 +34,24 @@ An application allowing to monitor the state of servers and requests of differen
* Server Configuration - global, google, hipchat, slack, mail and jobs settings.
* Client Configuration - display setting for request types, links and the page refresh interval.

See examples in the config.js.dev in the project

<h2>Web Management Console (for admin role only):</h2>

* User Management.
* Server Management. (No enviroment additions/deletions available)

<h2>Setup and Local Use:</h2>

* Create config.js in the root folder of the project (- rename config.js.dev to config.js and replace with your values)
* Create a google app with Google+ API enabled in the google developers console
* Update the google clientId, secret and callback in the config.

Database setup:

1. Enter mongo console by running: "mongo"
2. Create the devflow db: "use devflow"
3. Run the following scripts for initial population and creation of collections:

Users:
See examples in the config.js.dev in the project

db.Users.insert({id: null, email:'[email protected]', name: null, image: null, associated: false, role: "admin" })
<h2>Web Management Console:</h2>

Servers:

db.ServerEnvironments.insert({name: "Env1", order: 1, queue: [], servers: [{environment: "Env1", name:"Server11", queue: [], taken_since: null, user: null, url: null},{environment: "Env1", name:"Server12", queue: [], taken_since: null, user: null, url: null}]})
db.ServerEnvironments.insert({name: "Env2", order: 2, queue: [], servers: [{environment: "Env2", name:"Server21", queue: [], taken_since: null, user: null, url: null},{environment: "Env2", name:"Server22", queue: [], taken_since: null, user: null, url: null}]})

Please Run "npm install" on first use or if changing node packages.

In order to run locally please add this line to your hosts file:

127.0.0.1 devflow.yourdomain.com # devflow

Run with "npm start"

(In order to debug it's possible to run "node debug app.js" - node's built-in debugger, breakpoints using: "debugger", evaluating vars: "repl", regular debug control commands)

Enter: http://devflow.yourdomain.com:3000/ or localhost:3000
* User Management. (admin role only)
* Server Management. (admin role only, no enviroment additions/deletions available)
* Tags Management

<h2>Deploy and Production Settings:</h2>

configuration setup:
Configuration setup:

use: export DEVFLOW_CONFIG=path in order to add a path to your production config.
For custom configuration path use: export DEVFLOW_CONFIG=path.
(you can also include this in your .bash_profile or .bashrc)

Kill all node/npm processes related to devflow, for example:

ps -eaf | grep node
ps -eaf | grep npm
kill x, y ,z

Pull from master:

git pull origin master

Install packages if neccessary:

npm install

Run devflow in background on server:
Deploy latest version and Restart (on Linux):

NODE_ENV=production nohup npm start &
Enter your folder and run: ./deploy

Log and Errors:

Expand Down
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ d.on('error', function(err) {
});

// start server
nodeServer.listen(port, function(){
nodeServer.listen(port, function() {
console.log('Devflow server listening on port ' + port);
});
43 changes: 31 additions & 12 deletions config.js.dev
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ module.exports = function(env) {

sessionSecret: 'yourSecret',
mongo: 'mongodb://localhost:27017/devflow',
domain: 'yourdomain',
home_url: 'yoururl',
domain: '{{domainName}}',
home_url: 'devflow.{{domainName}}.com',
google: {
clientId: '',
clientSecret: '',
callbackURL: ''
clientId: '{{googleClientID}}',
clientSecret: '{{googleClientSecret}}',
callbackURL: '{{googleCallbackURL}}'
},
mail: {
isEnabled: false
Expand All @@ -23,11 +23,12 @@ module.exports = function(env) {
rooms: {}
},
github: {
organization: 'yourorg',
organization: '{{domainName}}',
accessToken: ''
},
requests: {
notifyRepos: false,
notifyTags: false
},
jobs: {
serverRelease: {
Expand All @@ -43,7 +44,7 @@ module.exports = function(env) {
types: ['BE', 'Team1', 'Team2', 'Team3'],
typeTitle: 'Team',
linkTitle: 'Link',
linkRegex: '^http://graylog.yourdomain.com/',
linkRegex: '^http://graylog.{{domainName}}.com/',
useSmallLabels: true,
constantEnv: 'Graylog Link',
rejectable: false,
Expand All @@ -58,7 +59,14 @@ module.exports = function(env) {
hasNumber: true,
rejectable: true,
showTeam: true,
rejectionReasons: {}
rejectionReasons: {
performance: 'Performance issues',
missing: 'Missing implementation',
structure: 'Code structure',
style: 'Code styling - only major styling issues',
verify: 'Needs verification with 3rd party',
other: 'Other'
}
}
},

Expand All @@ -76,16 +84,26 @@ module.exports = function(env) {
development: {
port: 3000,
google: {
clientId: '',
clientSecret: '',
callbackURL: ''
clientId: '{{googleClientID}}',
clientSecret: '{{googleClientSecret}}',
callbackURL: '{{googleCallbackURL}}'
}
},

production: {
port: 3005,
hipchat: {
isEnabled: true,
isEnabled: false,
authToken: '',
rooms: {
pullrequest: 1,
graylog: 2,
server: 3
}
},
slack: {
isEnabled: false,
icon: '',
authToken: '',
rooms: {
pullrequest: 1,
Expand All @@ -95,6 +113,7 @@ module.exports = function(env) {
},
requests: {
notifyRepos: true,
notifyTags: true
},
mail: {
isEnabled: false,
Expand Down
11 changes: 11 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

PROCESS_ID=`pwdx $(pgrep npm) | grep devflow | cut -d ":" -f 1`
if [ -n "$PROCESS_ID" ]; then
kill $PROCESS_ID || true
fi

git reset --hard origin/master
git pull -r
npm install
sleep 5
NODE_ENV=production nohup npm start &
2 changes: 2 additions & 0 deletions models/serverEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ serverSchema.methods.release = function(env) {
if (this.queue.length > 0) {
nextUser = this.queue[0];
this.queue.splice(0, 1);
} else if (env.queue.length > 0) {
nextUser = env.queue[0]; // removal from queue in next event
}

this.user = nextUser;
Expand Down
Loading

0 comments on commit 4941688

Please sign in to comment.