Skip to content

Commit a7931c0

Browse files
committed
bumped node requirement, requires forever, environment specific extension
1 parent fd4d67e commit a7931c0

File tree

7 files changed

+62
-24
lines changed

7 files changed

+62
-24
lines changed

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ Applications built with Periodic range from simple blogs, complicated enterprise
2727

2828
### Quick start guide
2929
```
30-
$ npm start --e [name-of-environment (development by default)]
30+
$ npm start --e [name-of-environment (development by default)] # runs nodemon
31+
$ npm run forever --e [name-of-environment (development by default)] # runs forever + nodemon
32+
$ npm run deploy --e [name-of-environment (development by default)] # deploys with pm2
33+
$ npm run sync # syncs dependencies
3134
```
3235

3336
| [![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) |

app/lib/config.js

+26-3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ var config = function () {
3434
configurationFileJSON,
3535
configurationOverrideFileJSON,
3636
configurationDefaultFileJSON,
37+
lastRuntimeEnvironment,
38+
lastRuntimeEnvironmentFilePath = path.resolve(process.cwd(), 'content/config/process/runtime.json'),
3739
config = {};
3840

3941
/**
@@ -83,6 +85,10 @@ var config = function () {
8385
this.init = function () {
8486
/** get info from package.json */
8587
packagejsonFileJSON = fs.readJSONSync(path.resolve(process.cwd(), './package.json'));
88+
/** get info from last runtime environemnt */
89+
if(fs.existsSync(lastRuntimeEnvironmentFilePath)){
90+
lastRuntimeEnvironment = fs.readJSONSync(lastRuntimeEnvironmentFilePath).environment;
91+
}
8692

8793
/** load user config file: content/config/config.json */
8894
configurationOverrideFileJSON = fs.readJSONSync(configurationOverrideFile);
@@ -95,12 +101,29 @@ var config = function () {
95101
if (process.env.NODE_ENV) {
96102
appEnvironment = process.env.NODE_ENV;
97103
}
104+
else if(argv.e){
105+
appEnvironment = argv.e;
106+
}
107+
else if(lastRuntimeEnvironment){
108+
appEnvironment = lastRuntimeEnvironment;
109+
}
110+
else if(typeof configurationOverrideFileJSON.application !== 'undefined' && typeof configurationOverrideFileJSON.application.environment !== 'undefined'){
111+
appEnvironment = configurationOverrideFileJSON.application.environment;
112+
}
98113
else {
99-
appEnvironment = (argv.e) ?
100-
argv.e : (typeof configurationOverrideFileJSON.application !== 'undefined' && typeof configurationOverrideFileJSON.application.environment !== 'undefined') ?
101-
configurationOverrideFileJSON.application.environment : 'development';
114+
appEnvironment = 'development';
102115
}
103116

117+
//** save last runtime environment to load as a backup */
118+
fs.outputJson(path.resolve(process.cwd(),'content/config/process/runtime.json'),{environment:appEnvironment},function(err){
119+
if(err){
120+
console.error(err);
121+
}
122+
else{
123+
console.log('saved runtime environment',appEnvironment);
124+
}
125+
});
126+
104127
/** set & load file path for base environment config */
105128
configurationFile = this.getConfigFilePath(appEnvironment);
106129

app/routes/index.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ module.exports = function (periodic) {
3636
var homeController = require('../controller/home')(periodic),
3737
appRouter = periodic.express.Router(),
3838
ignoreExtensionIndex,
39-
ExtensionCore = new Extensions(periodic.settings);
39+
ExtensionCore;
40+
41+
if(periodic.settings.use_test_extensions_by_environment){
42+
periodic.settings.extensionFilePath = path.resolve(process.cwd(), 'content/config/process/'+periodic.settings.application.environment+'.extensions.json');
43+
}
44+
ExtensionCore = new Extensions(periodic.settings);
45+
4046

4147
/** load extensions */
4248
periodic.settings.extconf = ExtensionCore.settings();

content/config/environment/default.json

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
},
1818
"session_secret":"hjoiuu87go9hui",
1919
"expressCompression": true,
20+
"use_test_extensions_by_environment": false,
2021
"templateengine": "ejs",
2122
"templatepackage": "ejs",
2223
"templatefileextension": "ejs",

package.json

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "periodicjs",
33
"description": "Periodic is an application framework built on top of Express and MongoDB designed for data driven, content based web and mobile applications.",
4-
"version": "3.1.1",
4+
"version": "3.1.2",
55
"main": "index.js",
66
"engines": {
77
"node": ">=0.10.31"
@@ -33,15 +33,14 @@
3333
"url": "git://github.com/typesettin/periodicjs.git"
3434
},
3535
"scripts": {
36-
"nd": "NODE_ENV=development nodemon --watch app --watch content/config/restart.json --watch content/config/database.js index.js ",
3736
"start": "node index.js --cli --nd --e",
38-
"stop": "pm2 delete periodicjs",
37+
"forever": "forever start -o logs/app-out.forever.log -e logs/app-err.forever.log -c nodemon index.js --e",
38+
"stop": "forever stop -c nodemon index.js",
39+
"deploy": "node index.js --cli --deploy",
3940
"test": "mocha -R spec --recursive",
4041
"coverage": "mocha -R html-cov --recursive > test/coverage.html",
4142
"postinstall": "node scripts/install.js",
42-
"deploysync": "node scripts/deploymentsync.js",
43-
"deploy_dev": "node index.js --cli --deploy dev",
44-
"deploy_prod": "node index.js --cli --deploy production"
43+
"sync": "node scripts/deploymentsync.js"
4544
},
4645
"dependencies": {
4746
"async": "0.9.0",

releases/3.1.2.md

+19-9
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,24 @@
55
* moving extension config to `content/config/extensions.json`
66
* moved restart.json to `content/config`
77
* added enterprise data security requirements for dbseed, custom data scrubbing
8-
* requires node >= 0.10.31, npm >= 2.0.0
8+
* added support for environemnt specific extensions for testing
9+
* **requires node >= 0.10.31, npm >= 2.0.0**
910

1011
### Notes
11-
* Periodic Migration guide from 3.0.0
12-
```
13-
# move content/extensions/extensions.json, content/extensions/log, content/extensions/restart.json to content/config
14-
# delete content/extensions directory
15-
# install latest version of periodic
16-
$ cd /path/to/web/app
17-
$ npm install [email protected] --prefix ./ # or $ npm install periodicjs@latest
18-
```
12+
#### Periodic Migration guide from 3.0.0
13+
```
14+
# move content/extensions/extensions.json, content/extensions/log, content/extensions/restart.json to content/config
15+
# delete content/extensions directory
16+
# install latest version of periodic
17+
$ npm install forever -g # install forever
18+
$ cd /path/to/web/app
19+
$ npm install [email protected] --prefix ./ # or $ npm install periodicjs@latest
20+
```
21+
#### Periodic Runtime Options
22+
```
23+
$ npm start --e [name-of-environment (development by default)] # runs nodemon
24+
$ npm run forever --e [name-of-environment (development by default)] # runs forever + nodemon
25+
$ npm run deploy --e [name-of-environment (development by default)] # deploys with pm2
26+
$ npm run sync # syncs dependencies
27+
```
28+
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

scripts/deploymentsync.js

-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,5 @@ async.waterfall([
2727
else{
2828
console.log('deployment sync result',result);
2929
CoreUtilities.restart_app({});
30-
CoreUtilities.run_cmd( 'pm2', ['restart','periodicjs'], function(text) {
31-
console.log (text);
32-
process.exit(0);
33-
});
3430
}
3531
});

0 commit comments

Comments
 (0)