I'm getting this error when trying to restart the gateway.service (running on a Raspberry Pi 2B with Raspbian GNU/Linux 9.11 stretch, Gateway version 9.0.0, I haven't gotten an opportunity to upgrade to 9.1 or 9.2 yet)
$ tail /home/pi/gateway/logs/gateway.sys.log
[12-01-20_19:48:17.151] [INFO] LOADING USER METRICS...
[12-01-20_19:48:17.175] [INFO] LOADING USER METRICS MODULE [_InternetSpeedTest.js]
[12-01-20_19:48:17.202] [INFO] LOADING USER METRICS MODULE [_example.js]
[12-01-20_19:48:17.228] [INFO] LOADING USER METRICS MODULE [_garage-auto-close.js]
/home/pi/gateway-v9.0.0/node_modules/nedb/lib/datastore.js:77
if (err) { throw err; }
^
RangeError [ERR_FS_FILE_TOO_LARGE]: File size (2923528192) is greater than possible Buffer: 1073741823 bytes
at FSReqCallback.readFileAfterStat [as oncomplete] (fs.js:269:11)
I did try disabling both of my custom user metrics, that did not help, same error. I'm guessing my metrics database got too large (based on the error message). I know when I was messing with the gateway last week, I did run the "compact database" command from the web UI, if that makes any difference.
Update 1: Well, I found the problem, my new fancy custom user metric to reset my monthly water usage (on a waterMote) didn't just fire once, it fired A LOT of times, bringing my ~/gateway/data/db/gateway.db file up to 2789 MB. What format is this database file in and what tools can I use to prune the junk out of it, so I can restore it to normal operation? Is it just a giant JSON file, and I just need to find the bad entries and delete them?
Update 2: It was indeed just a giant JSON file, and I was able to use a combination of grep and jq to filter out all the bad junk. Back down to 3MB and everything looks to be working again!
For anyone looking to NOT repeat what I did here,
I proudly posted my new function over here last week. If anyone would like to point out where I went wrong there, so myself and others can learn from the mistake, I welcome the feedback =]