simov / express-admin

MySQL, MariaDB, PostgreSQL, SQLite admin for Node.js
MIT License
1.17k stars 223 forks source link

Heroku Error: EROFS: read-only file system, open '../../settings.json' #110

Closed jforaker closed 8 years ago

jforaker commented 8 years ago

Trying to add this to an app on Heroku, having some difficulties. My setup works locally but getting this error on Heroku:

016-06-12T06:30:38.552107+00:00 app[web.1]: fs.js:549
2016-06-12T06:30:38.552121+00:00 app[web.1]:   return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
2016-06-12T06:30:38.552123+00:00 app[web.1]:                                                   ^
2016-06-12T06:30:38.552124+00:00 app[web.1]:
2016-06-12T06:30:38.552125+00:00 app[web.1]: Error: EROFS: read-only file system, open '../../settings.json'
2016-06-12T06:30:38.552126+00:00 app[web.1]:     at Error (native)
2016-06-12T06:30:38.552127+00:00 app[web.1]:     at Object.fs.openSync (fs.js:549:18)
2016-06-12T06:30:38.552127+00:00 app[web.1]:     at Object.fs.writeFileSync (fs.js:1161:15)
2016-06-12T06:30:38.552128+00:00 app[web.1]:     at /app/node_modules/express-admin/app.js:82:8
2016-06-12T06:30:38.552129+00:00 app[web.1]:     at /app/node_modules/express-admin/lib/db/schema.js:42:3
2016-06-12T06:30:38.552131+00:00 app[web.1]:     at done (/app/node_modules/express-admin/node_modules/async/lib/async.js:135:19)
2016-06-12T06:30:38.552131+00:00 app[web.1]:     at /app/node_modules/express-admin/node_modules/async/lib/async.js:32:16
2016-06-12T06:30:38.552132+00:00 app[web.1]:     at done (/app/node_modules/express-admin/node_modules/async/lib/async.js:135:19)
2016-06-12T06:30:38.552133+00:00 app[web.1]:     at /app/node_modules/express-admin/node_modules/async/lib/async.js:32:16
2016-06-12T06:30:38.552133+00:00 app[web.1]:     at /app/node_modules/express-admin/lib/db/schema.js:37:6

I know its probably has to to with the read-only filesystem on heroku, but wondering if someone can point me in the right direction.

(also love the project, thanks!)

simov commented 8 years ago

First thing that comes to mind is to make sure your settings.json file have the right permissions:

chmod 777 settings.json

Then commit and push to heroku again.

jforaker commented 8 years ago

Ok, I tried that as well running that command on the heroku shell.. still the same issue :/

jforaker commented 8 years ago

Ok I just tried installing this on a fresh application on heroku, and got it to work. Must have been my pathing scheme was incorrect before. Basically I wanted to embed it with another api application on heroku, but i'm just having too much trouble getting both apps to run on the same server.

Fwiw - here is my setup that is working on heroku

index.js:

var express = require('express');
var xAdmin = require('express-admin');
var bodyParser = require('body-parser');
var path = require('path');

var prod = process.env.NODE_ENV === 'production';
var adminConfig = prod ? require('./config.js') : require(path.resolve(__dirname, './configDev.json'));
var config = {
    dpath: './',
    config: adminConfig,
    settings: require('./settings'),
    custom: require('./custom'),
    users: require('./users')
};
var port = process.env.PORT || 3000;

xAdmin.init(config, function (err, admin) {
    if (err) return console.log(err);
    var app = express();
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({extended: true}));
    app.use('/admin', admin);
    app.get('/', function (req, res) {
        res.send('Hello World');
    });
    app.listen(port, function () {
        console.log('My awesome site listening on port 3000');
    });
});

config.js

module.exports = {
  "pg": {
    "database": "d40v.....",
    "user": "fjgk....",
    "password": "L5IUh....",
    "host": "ec2-.........compute-1.amazonaws.com",
    "port": 5432,
    "name": "d40v......",
    "schema": "public",
    "ssl": true
  },
  "app": {
    "layouts": true,
    "themes": true,
    "languages": true,
    "root": "/admin"
  }
};

file structure: image