mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
Logging in main, old code removal
This commit is contained in:
parent
7a40666a8f
commit
0bf83b721b
3 changed files with 63 additions and 96 deletions
61
server.js
61
server.js
|
@ -1,3 +1,23 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
|
||||
Question Server
|
||||
GitLab: <https://gitlab.com/YourFriendlyNeighborhoodDealer/question-node-server>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
const express = require('express')
|
||||
const vhost = require('vhost')
|
||||
const logger = require('./logger.js')
|
||||
|
@ -5,15 +25,52 @@ const logger = require('./logger.js')
|
|||
const qmining = require('./qmining.js').app
|
||||
const main = require('./main.js').app
|
||||
|
||||
const stat = require('./stat.js')
|
||||
stat.Load()
|
||||
|
||||
const port = 8080
|
||||
|
||||
function AddLogger (app) {
|
||||
app.use(function (req, res, next) {
|
||||
res.on('finish', function () {
|
||||
logger.LogReq(req, true, res.statusCode)
|
||||
if (res.statusCode !== 404) { stat.LogStat(req.url) }
|
||||
})
|
||||
next()
|
||||
})
|
||||
}
|
||||
|
||||
AddLogger(qmining)
|
||||
AddLogger(main)
|
||||
|
||||
// // https://certbot.eff.org/
|
||||
// const privkeyFile = '/etc/letsencrypt/live/qmining.tk/privkey.pem'
|
||||
// const fullchainFile = '/etc/letsencrypt/live/qmining.tk/fullchain.pem'
|
||||
// const chainFile = '/etc/letsencrypt/live/qmining.tk/chain.pem'
|
||||
//
|
||||
// var certsLoaded = false
|
||||
// if (startHTTPS && utils.FileExists(privkeyFile) && utils.FileExists(fullchainFile) && utils.FileExists(
|
||||
// chainFile)) {
|
||||
// try {
|
||||
// const key = fs.readFileSync(privkeyFile, 'utf8')
|
||||
// const cert = fs.readFileSync(fullchainFile, 'utf8')
|
||||
// const ca = fs.readFileSync(chainFile, 'utf8')
|
||||
// var certs = {
|
||||
// key: key,
|
||||
// cert: cert,
|
||||
// ca: ca
|
||||
// }
|
||||
// certsLoaded = true
|
||||
// } catch (e) {
|
||||
// logger.Log('Error loading cert files!', logger.GetColor('redbg'))
|
||||
// }
|
||||
// }
|
||||
|
||||
express()
|
||||
.use(vhost('qmining.frylabs.net', qmining))
|
||||
.use(vhost('frylabs.net', main))
|
||||
.use(vhost('qmining.tk', qmining))
|
||||
.listen(port)
|
||||
|
||||
|
||||
logger.Log('Node version: ' + process.version)
|
||||
logger.Log('Listening on port: ' + port)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue