Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncing from original #1

Merged
merged 11 commits into from
Sep 1, 2019
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"prototypejs": false,
"mootools": false,
"dojo": false,
"esversion": 5,

"devel": true,

Expand Down Expand Up @@ -50,4 +51,4 @@
"trailing": true,
"white": false,
"indent": 2
}
}
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
sudo: false
language: node_js
node_js:
- 4.6
- 6.9
- 4
- 6
- 8
- 10
- 11
branches:
only:
- master
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@

1.0.0 / Web, 03 Apr 2019
=========================

- [major] 1.0.0 due to breaking change introduced in [#1017].
- [security] Update utile to get rid of security warning [#1022]
- [security] Remove dependency on timespan [#1014]
- [fix] Fix support for Node 10+ [#979]
- [change] Propagate error when failing to create directories on startup [#1017]
- [doc] Add example for referencing -l -o and -e parameters from within a JSON config file [#869]

0.14.2 / Tue, 30 Jun 2015
=========================
* [804b5b1](https://github.com/foreverjs/forever/commit/804b5b1) [dist] Version bump. 0.14.2 (`indexzero`)
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ In addition to passing forever the path to a script (along with accompanying opt
"append": true,
"watch": true,
"script": "index.js",
"sourceDir": "/home/myuser/app"
"sourceDir": "/home/myuser/app",
"logFile": "/home/myuser/logs/forever.log",
"outFile": "/home/myuser/logs/out.log",
"errFile": "/home/myuser/logs/error.log"
}
```

Expand Down
42 changes: 21 additions & 21 deletions lib/forever.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ var fs = require('fs'),
cliff = require('cliff'),
nconf = require('nconf'),
nssocket = require('nssocket'),
timespan = require('timespan'),
utile = require('utile'),
winston = require('winston'),
mkdirp = utile.mkdirp,
async = utile.async;
mkdirp = require('mkdirp'),
async = require('async'),
configUtils = require('./util/config-utils');

var forever = exports;

Expand Down Expand Up @@ -50,7 +50,7 @@ forever.initialized = false;
forever.kill = require('forever-monitor').kill;
forever.checkProcess = require('forever-monitor').checkProcess;
forever.root = process.env.FOREVER_ROOT || path.join(process.env.HOME || process.env.USERPROFILE || '/root', '.forever');
forever.config = new nconf.File({ file: path.join(forever.root, 'config.json') });
forever.config = configUtils.initConfigFile(forever.root);
forever.Forever = forever.Monitor = require('forever-monitor').Monitor;
forever.Worker = require('./forever/worker').Worker;
forever.cli = require('./forever/cli');
Expand Down Expand Up @@ -335,22 +335,9 @@ forever.load = function (options) {
forever._debug();
}

//
// Syncronously create the `root` directory
// and the `pid` directory for forever. Although there is
// an additional overhead here of the sync action. It simplifies
// the setup of forever dramatically.
//
function tryCreate(dir) {
try {
fs.mkdirSync(dir, '0755');
}
catch (ex) { }
}

tryCreate(forever.config.get('root'));
tryCreate(forever.config.get('pidPath'));
tryCreate(forever.config.get('sockPath'));
configUtils.tryCreateDir(forever.config.get('root'));
configUtils.tryCreateDir(forever.config.get('pidPath'));
configUtils.tryCreateDir(forever.config.get('sockPath'));

//
// Attempt to save the new `config.json` for forever
Expand Down Expand Up @@ -1037,7 +1024,20 @@ forever.columns = {
uptime: {
color: 'yellow',
get: function (proc) {
return proc.running ? timespan.fromDates(new Date(proc.ctime), new Date()).toString().yellow : "STOPPED".red;
if (!proc.running) {
return "STOPPED".red;
}

var delta = (new Date().getTime() - proc.ctime) / 1000;
var days = Math.floor(delta / 86400);
delta -= days * 86400;
var hours = Math.floor(delta / 3600) % 24;
delta -= hours * 3600;
var minutes = Math.floor(delta / 60) % 60;
delta -= minutes * 60;
var seconds = delta % 60;

return (days+':'+hours+':'+minutes+':'+seconds).yellow;
}
}
};
2 changes: 1 addition & 1 deletion lib/forever/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Worker.prototype.start = function (callback) {
// as a mapping to the `\\.pipe\\*` "files" that can't
// be enumerated because ... Windows.
//
fs.unlink(self._sockFile);
fs.unlinkSync(self._sockFile);
}

self.monitor.stop();
Expand Down
29 changes: 29 additions & 0 deletions lib/util/config-utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var path = require('path');
var fs = require('fs');
var nconf = require('nconf');

function initConfigFile(foreverRoot) {
return new nconf.File({file: path.join(foreverRoot, 'config.json')});
}

//
// Synchronously create the `root` directory
// and the `pid` directory for forever. Although there is
// an additional overhead here of the sync action. It simplifies
// the setup of forever dramatically.
//
function tryCreateDir(dir) {
try {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, '0755');
}
}
catch (error) {
throw new Error('Failed to create directory '+dir+":" +error.message);
}
}

module.exports = {
initConfigFile: initConfigFile,
tryCreateDir: tryCreateDir
};
Loading