LowPowerLab Forum

Software support => Pi Gateway => Topic started by: jonedw on May 21, 2016, 11:37:14 PM

Title: Gateway installation question - gateway.js
Post by: jonedw on May 21, 2016, 11:37:14 PM
I am in the process of working on a fresh installation of the gateway but I have hit a brick wall on a issue when I try to start gateway.JS.  The following error appears that seems to point out that gateway.db can not be opened:

pi@raspberrypi:~/gateway $ node gateway.js &
[1] 1665
pi@raspberrypi:~/gateway $ /home/pi/gateway/node_modules/nedb/lib/datastore.js:77
    if (err) { throw err; }
                     ^
Error: ENOENT, open '/home/pi/gateway/data/db/gateway.db'
    at Error (native)

[1]+  Exit 1                  node gateway.js

Any clues what I may have missed during my setup?
Title: Re: Gateway installation question - gateway.js
Post by: Scram on May 22, 2016, 05:39:37 AM
May be a access rights problem on file '/home/pi/gateway/data/db/gateway.db' !?

Mine has :
rights: rw-r--r--
user: pi
Title: Re: Gateway installation question - gateway.js
Post by: jonedw on May 22, 2016, 02:33:22 PM
gateway.db does not exist.  It looks like the gateway.js script is not creating the db. 

The sub folder /gateway/data permissions look correct:

drwxr-xr-x 2 root root 4096 May 20 21:05 db
drwxr-xr-x 2 root root 4096 May 20 18:55 secure


Title: Re: Gateway installation question - gateway.js
Post by: Felix on May 22, 2016, 10:17:08 PM
ENOENT means it can't find the db file.
If you look at the nedb docs, the way the constructor is built is to create the file the first time it is written to. Here's the line in gateway.js (https://github.com/LowPowerLab/RaspberryPi-Gateway/blob/master/gateway.js#L43):

var db = new Datastore({ filename: path.join(__dirname, dbDir, settings.database.name.value), autoload: true });       //used to keep all node/metric data
Title: Re: Gateway installation question - gateway.js
Post by: jonedw on May 23, 2016, 09:02:08 PM
Felix, I do see that line in gateway.js and as far as I can see it should be creating the gateway.db file. 

I know it is a stretch, but do you have any idea what I may have missed in the setup that would prevent the creation of the gateway.db by the script? 

I have reviewed the steps in the setup instructions multiple times and I can not see what I have missed.
Title: Re: Gateway installation question - gateway.js
Post by: Felix on May 24, 2016, 10:29:45 AM
Not sure what you missed, but if you do a manual install make sure you have the latest code from the master branch.
I just pasted that code directly from github so maybe you have stale code.