Commit b0d748df authored by yPhil's avatar yPhil
Browse files

Version 1.1 - Plandemic

parent e9dfe3ab
......@@ -2,19 +2,20 @@ var express = require('express'),
path = require('path'),
index = require('./routes/index'),
fs = require('fs'),
pjson = require('./package.json'),
app = express();
var bodyParser = require('body-parser');
if (!fs.existsSync(path.join(__dirname, process.env.FAVICONS_CACHE_DIR))){
fs.mkdirSync(path.join(__dirname, process.env.FAVICONS_CACHE_DIR));
if (!fs.existsSync(path.join(__dirname, pjson.FAVICONS_CACHE_DIR))){
fs.mkdirSync(path.join(__dirname, pjson.FAVICONS_CACHE_DIR));
}
app.set('views', path.join(__dirname, 'views'));
app.engine('html', require('ejs').renderFile);
app.set('view engine', 'html');
app.use('/favicons', express.static(path.join(__dirname, process.env.FAVICONS_CACHE_DIR)));
app.use('/favicons', express.static(path.join(__dirname, pjson.FAVICONS_CACHE_DIR)));
app.use('/static', express.static(path.join(__dirname, 'public')));
app.use('/bower', express.static(path.join(__dirname, 'bower_components')));
......
......@@ -16,7 +16,8 @@ function isLocal() {
}
}
console.log('ENV: ' + process.env.NODE_ENV);
console.log('### ENV: ' + process.env.NODE_ENV);
console.log('## PORT: ' + port);
// if (!isLocal) {
......
......@@ -4,6 +4,7 @@
"version": "1.0.46",
"private": true,
"license": "GPL-3.0-only",
"FAVICONS_CACHE_DIR": "favicons-cache",
"engines": {
"node": "*"
},
......@@ -12,12 +13,12 @@
"url": "https://framagit.org/yphil/petrolette"
},
"scripts": {
"start": "pm2 start pm2.config.json ; pm2 update",
"start-ssl": "pm2 start pm2.config.json --env ssl",
"restart": "pm2 restart pm2.config.json",
"stop": "pm2 stop petrolette",
"show": "pm2 show petrolette",
"log": "pm2 logs petrolette",
"start": "./node_modules/pm2/bin/pm2 start pm2.config.json ; ./node_modules/pm2/bin/pm2 update",
"start-ssl": "./node_modules/pm2/bin/pm2 start pm2.config.json --env ssl",
"restart": "./node_modules/pm2/bin/pm2 restart pm2.config.json",
"stop": "./node_modules/pm2/bin/pm2 stop petrolette",
"show": "./node_modules/pm2/bin/pm2 show petrolette",
"logs": "./node_modules/pm2/bin/pm2 logs petrolette",
"postinstall": "bower install --allow-root"
},
"dependencies": {
......@@ -31,7 +32,7 @@
"gitlab-runner": "0.0.10",
"iconv": "^3.0.0",
"npm": "^7.3.0",
"pm2": "^4.5.2",
"pm2": "^4.5.1",
"request": "latest"
}
}
......@@ -7,14 +7,12 @@
"ignore_watch" : ["#*", "favicons-cache", ".git", "node_modules"],
"log_date_format" : "YYYY-MM-DD HH:mm",
"env" : {
"PORT" : 8080,
"NODE_ENV": "dev",
"FAVICONS_CACHE_DIR": "favicons-cache"
"PORT" : 8000,
"NODE_ENV": "dev"
},
"env_ssl" : {
"PORT" : 8080,
"NODE_ENV": "ssl",
"FAVICONS_CACHE_DIR": "favicons-cache"
"NODE_ENV": "ssl"
}
}
]
......
......@@ -96,7 +96,7 @@ function getFeed (urlfeed, callback) {
req
.on ('error', function (err) {
callback(err.toString());
callback(err.message);
})
.on ('response', function (res) {
if (res.statusCode != 200) return this.emit('error', new Error('Bad status code'));
......@@ -119,8 +119,8 @@ function getFeed (urlfeed, callback) {
})
.on ('error', function (err) {
var meta = this.meta;
console.log('HUUM (%s) %s %s', err, meta.title, urlfeed);
// callback ('err');
console.log('HUUM (%s) %s %s', err.message, meta.title, urlfeed);
callback (err.message);
})
.on ('end', function () {
var meta = this.meta;
......@@ -138,6 +138,7 @@ router.get('/feed', function(req, res) {
dnsreq
.on('error', function(error) {
// The only way so far to catch a DNS error
console.log('Err: %s (%s)', {error:error.code}, req.query.feedurl);
res.send({error:error.code});
})
.on('response', function(response) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment