UNPKG

1.12 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3var fs = require('fs'),
4 path = require('path'),
5 cwd = process.cwd(),
6 argv = require('yargs').argv;
7
8var configFileName = path.resolve(cwd, argv.config || argv._[0] || 'watchalive.json')
9
10var options = {}
11
12if (fs.existsSync(configFileName)){
13 try {
14 console.log('Reading configuration file', configFileName)
15 var fileConfig = JSON.parse(fs.readFileSync(configFileName))
16 options = fileConfig
17 } catch(e){
18 console.log('Could parse watchalive configuration file', e)
19 }
20}
21
22//if (!!global.gc) {
23// console.log('Garbage collector is available on global scope')
24// setInterval(function() {
25// try {
26// global.gc()
27// } catch (gcerr) {
28// console.log('Garbage collecting error', gcerr)
29// }
30// }, 1000 * 30)
31//} else {
32// console.log('--expose-gc flag wasn\'t provided')
33//}
34
35function takeParamFromArgs(param){
36 options[param] = argv[param] || argv[param[0]] || options[param]
37}
38
39;['base', 'port'].forEach(takeParamFromArgs)
40
41var App = require('./lib/app.js')
42
43var app = new App(options)
44
45app.start()
\No newline at end of file