在生产模式下,在现有节点应用程序中运行Ghost

我在现有的Node.js应用程序中使用Ghost,并使用以下configuration:

// ### Development **(default)** development: { // The url to use when providing links to the site, Eg in RSS and email. // Change this to your Ghost blogs published URL. url: 'http://localhost:2368/blog', database: { client: 'sqlite3', connection: { filename: path.join(__dirname, '/content/data/ghost-dev.db') }, debug: false }, server: { // Host to be passed to node's `net.Server#listen()` host: 'localhost', // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` port: '2368' } } 

不过,我用Postgresql将我的应用程序部署到Heroku,所以我在这里有一个生产configuration:

 production: { url: 'https://summittalks.herokuapp.com:2368/blog', mail: {}, database: { client: 'postgres', connection: { host: 'MY_HOST', user: 'MY_USER', password: 'MY_PASS', database: 'MY_DB', port: 'MY_PORT' }, debug: false }, server: { // Host to be passed to node's `net.Server#listen()` host: '0.0.0.0', // Port to be passed to node's `net.Server#listen()`, for iisnode set this to `process.env.PORT` port: '2368' }, fileStorage: false } 

我正在将Ghost加载到我的Node.js应用程序中,如下所示:

 app.modules.ghost({ config: app.utilities.path.join(__dirname, '/ghost/ghost.js') }).then(function(ghostServer){ app.express.use(ghostServer.config.paths.subdir, ghostServer.rootApp); ghostServer.start(app.express); }).then(function(req,res){ app.express.get('*', function(req,res){ res.status(404).send('<h1>404</h1><p>Page not found.</p>'); }); app.express.post('*', function(req,res){ res.status(404).json({error:'Resource not found'}); }); }); 

如何在生产中运行Ghost并告诉Heroku这样做? 我现在做:

node server.js dev

以开发模式运行我的应用程序。 如果“开发”不在那里,那么我的应用程序在生产模式下运行。 我想为Ghost应用一个类似的逻辑,但我不知道如何告诉它运行prod。

只需在Heroku应用程序目录的根目录下运行这一行:

$ heroku config:set NODE_ENV=production