Skip to content

Commit

Permalink
bumped node requirement, requires forever, environment specific exten…
Browse files Browse the repository at this point in the history
…sion
  • Loading branch information
yawetse committed Nov 25, 2014
1 parent fd4d67e commit a7931c0
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 24 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ Applications built with Periodic range from simple blogs, complicated enterprise

### Quick start guide
```
$ npm start --e [name-of-environment (development by default)]
$ npm start --e [name-of-environment (development by default)] # runs nodemon
$ npm run forever --e [name-of-environment (development by default)] # runs forever + nodemon
$ npm run deploy --e [name-of-environment (development by default)] # deploys with pm2
$ npm run sync # syncs dependencies
```

| [![Install home](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/install-start-screen.png)](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/install-start-screen.png) | [![Admin home](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/admin-content-dropdown.png)](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/admin-content-dropdown.png) | [![New Item](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/admin-item-new-2.png)](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/admin-item-new-2.png) | [![review revision](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/admin-review-revisions-collection.png)](https://raw.githubusercontent.com/typesettin/wiki-resources/master/images/periodic/admin-review-revisions-collection.png) |
Expand Down
29 changes: 26 additions & 3 deletions app/lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ var config = function () {
configurationFileJSON,
configurationOverrideFileJSON,
configurationDefaultFileJSON,
lastRuntimeEnvironment,
lastRuntimeEnvironmentFilePath = path.resolve(process.cwd(), 'content/config/process/runtime.json'),
config = {};

/**
Expand Down Expand Up @@ -83,6 +85,10 @@ var config = function () {
this.init = function () {
/** get info from package.json */
packagejsonFileJSON = fs.readJSONSync(path.resolve(process.cwd(), './package.json'));
/** get info from last runtime environemnt */
if(fs.existsSync(lastRuntimeEnvironmentFilePath)){
lastRuntimeEnvironment = fs.readJSONSync(lastRuntimeEnvironmentFilePath).environment;
}

/** load user config file: content/config/config.json */
configurationOverrideFileJSON = fs.readJSONSync(configurationOverrideFile);
Expand All @@ -95,12 +101,29 @@ var config = function () {
if (process.env.NODE_ENV) {
appEnvironment = process.env.NODE_ENV;
}
else if(argv.e){
appEnvironment = argv.e;
}
else if(lastRuntimeEnvironment){
appEnvironment = lastRuntimeEnvironment;
}
else if(typeof configurationOverrideFileJSON.application !== 'undefined' && typeof configurationOverrideFileJSON.application.environment !== 'undefined'){
appEnvironment = configurationOverrideFileJSON.application.environment;
}
else {
appEnvironment = (argv.e) ?
argv.e : (typeof configurationOverrideFileJSON.application !== 'undefined' && typeof configurationOverrideFileJSON.application.environment !== 'undefined') ?
configurationOverrideFileJSON.application.environment : 'development';
appEnvironment = 'development';
}

//** save last runtime environment to load as a backup */
fs.outputJson(path.resolve(process.cwd(),'content/config/process/runtime.json'),{environment:appEnvironment},function(err){
if(err){
console.error(err);
}
else{
console.log('saved runtime environment',appEnvironment);
}
});

/** set & load file path for base environment config */
configurationFile = this.getConfigFilePath(appEnvironment);

Expand Down
8 changes: 7 additions & 1 deletion app/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ module.exports = function (periodic) {
var homeController = require('../controller/home')(periodic),
appRouter = periodic.express.Router(),
ignoreExtensionIndex,
ExtensionCore = new Extensions(periodic.settings);
ExtensionCore;

if(periodic.settings.use_test_extensions_by_environment){
periodic.settings.extensionFilePath = path.resolve(process.cwd(), 'content/config/process/'+periodic.settings.application.environment+'.extensions.json');
}
ExtensionCore = new Extensions(periodic.settings);


/** load extensions */
periodic.settings.extconf = ExtensionCore.settings();
Expand Down
1 change: 1 addition & 0 deletions content/config/environment/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"session_secret":"hjoiuu87go9hui",
"expressCompression": true,
"use_test_extensions_by_environment": false,
"templateengine": "ejs",
"templatepackage": "ejs",
"templatefileextension": "ejs",
Expand Down
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "periodicjs",
"description": "Periodic is an application framework built on top of Express and MongoDB designed for data driven, content based web and mobile applications.",
"version": "3.1.1",
"version": "3.1.2",
"main": "index.js",
"engines": {
"node": ">=0.10.31"
Expand Down Expand Up @@ -33,15 +33,14 @@
"url": "git://github.com/typesettin/periodicjs.git"
},
"scripts": {
"nd": "NODE_ENV=development nodemon --watch app --watch content/config/restart.json --watch content/config/database.js index.js ",
"start": "node index.js --cli --nd --e",
"stop": "pm2 delete periodicjs",
"forever": "forever start -o logs/app-out.forever.log -e logs/app-err.forever.log -c nodemon index.js --e",
"stop": "forever stop -c nodemon index.js",
"deploy": "node index.js --cli --deploy",
"test": "mocha -R spec --recursive",
"coverage": "mocha -R html-cov --recursive > test/coverage.html",
"postinstall": "node scripts/install.js",
"deploysync": "node scripts/deploymentsync.js",
"deploy_dev": "node index.js --cli --deploy dev",
"deploy_prod": "node index.js --cli --deploy production"
"sync": "node scripts/deploymentsync.js"
},
"dependencies": {
"async": "0.9.0",
Expand Down
28 changes: 19 additions & 9 deletions releases/3.1.2.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@
* moving extension config to `content/config/extensions.json`
* moved restart.json to `content/config`
* added enterprise data security requirements for dbseed, custom data scrubbing
* requires node >= 0.10.31, npm >= 2.0.0
* added support for environemnt specific extensions for testing
* **requires node >= 0.10.31, npm >= 2.0.0**

### Notes
* Periodic Migration guide from 3.0.0
```
# move content/extensions/extensions.json, content/extensions/log, content/extensions/restart.json to content/config
# delete content/extensions directory
# install latest version of periodic
$ cd /path/to/web/app
$ npm install [email protected] --prefix ./ # or $ npm install periodicjs@latest
```
#### Periodic Migration guide from 3.0.0
```
# move content/extensions/extensions.json, content/extensions/log, content/extensions/restart.json to content/config
# delete content/extensions directory
# install latest version of periodic
$ npm install forever -g # install forever
$ cd /path/to/web/app
$ npm install [email protected] --prefix ./ # or $ npm install periodicjs@latest
```
#### Periodic Runtime Options
```
$ npm start --e [name-of-environment (development by default)] # runs nodemon
$ npm run forever --e [name-of-environment (development by default)] # runs forever + nodemon
$ npm run deploy --e [name-of-environment (development by default)] # deploys with pm2
$ npm run sync # syncs dependencies
```
Running npm start saves the environment in `content/config/process/runtime.json`, if no environment is specified, it will reload in this environment, this is helpful server restarts
4 changes: 0 additions & 4 deletions scripts/deploymentsync.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,5 @@ async.waterfall([
else{
console.log('deployment sync result',result);
CoreUtilities.restart_app({});
CoreUtilities.run_cmd( 'pm2', ['restart','periodicjs'], function(text) {
console.log (text);
process.exit(0);
});
}
});

0 comments on commit a7931c0

Please sign in to comment.