diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-05-06 18:51:30 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2021-05-06 18:51:30 +0200 |
commit | e2a88e6065988a637c6ac541ff4abf0181503f4f (patch) | |
tree | e08417b1003c06e9ffce3392bc2cbff3bb7d8efb | |
parent | edfb71ff2054ec41691ccc94237826011a3f9f13 (diff) | |
download | server-e2a88e6065988a637c6ac541ff4abf0181503f4f.tar.gz |
server: Save rotating HTTP access log.
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | server.js | 11 |
3 files changed, 11 insertions, 3 deletions
@@ -2,6 +2,7 @@ package-lock.json node_modules db sessions +log .env *.pem vassal diff --git a/package.json b/package.json index 93c4049..431f609 100644 --- a/package.json +++ b/package.json @@ -11,9 +11,11 @@ "ejs": "^3.1.5", "express": "^4.17.1", "express-session": "^1.17.1", + "morgan": "^1.10.0", "passport": "^0.4.1", "passport-local": "^1.0.0", "passport.socketio": "^3.7.0", + "rotating-file-stream": "^2.1.5", "socket.io": "^3.0.4" } } @@ -18,7 +18,7 @@ const SESSION_SECRET = "Caesar has a big head!"; const MAX_OPEN_GAMES = 3; -let sessionStore = new SQLiteStore(); +let session_store = new SQLiteStore(); let db = new sqlite3(process.env.DATABASE || "./db"); let app = express(); let http_port = process.env.PORT || 8080; @@ -36,6 +36,11 @@ let io = { on: function (ev,fn) { io1.on(ev,fn); io2.on(ev,fn); }, }; +const morgan = require('morgan'); +const rfs = require('rotating-file-stream'); +const log_file = rfs.createStream('access.log', { interval: '1d', path: 'log' }); +app.use(morgan('combined', {stream: log_file})); + app.disable('etag'); app.set('view engine', 'ejs'); app.use(body_parser.urlencoded({extended:false})); @@ -43,7 +48,7 @@ app.use(express_session({ secret: SESSION_SECRET, resave: false, saveUninitialized: true, - store: sessionStore, + store: session_store, cookie: { maxAge: 7 * 24 * 60 * 60 * 1000 } })); app.use(connect_flash()); @@ -51,7 +56,7 @@ app.use(connect_flash()); io.use(passport_socket.authorize({ key: 'connect.sid', secret: SESSION_SECRET, - store: sessionStore, + store: session_store, })); const is_immutable = /\.(svg|png|jpg|jpeg|woff2)$/; |