From 6e556afede9c43326b8fcd91c43d0940f03ad5a9 Mon Sep 17 00:00:00 2001 From: Sergio Oller Date: Mon, 17 Jun 2019 11:06:01 +0200 Subject: [PATCH] Prevent database is locked errors Since there are only SELECT statements, the database can be opened as read-only preventing: Error: SQLITE_BUSY: database is locked at Error (native) --- httpd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/httpd.js b/httpd.js index 829eaec..79d0337 100644 --- a/httpd.js +++ b/httpd.js @@ -7,7 +7,7 @@ var moment = require('moment'); var express = require("express"); var app = express(); -var db = new sqlite3.Database(DB_FILE); +var db = new sqlite3.Database(DB_FILE, sqlite3.OPEN_READONLY)); var isValidChart = function(s) { return /^(net_in|net_out|block_in|block_out|mem)$/.test(s); @@ -114,4 +114,4 @@ app.get("/rs/all/:chart/:zoom", function(req, res) { app.listen(8080, function() { -}); \ No newline at end of file +});