【发布时间】:2015-02-05 07:19:46
【问题描述】:
我在现有的 Node.js 应用程序中使用 Ghost,配置如下:
// ### Development **(default)**
development: {
// The url to use when providing links to the site, E.g. 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,所以我在这里有一个生产配置:
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
在开发模式下运行我的应用程序。如果“dev”不存在,那么我的应用程序在生产模式下运行。我想对 Ghost 应用类似的逻辑,但我不知道如何让它在 prod 中运行。
【问题讨论】:
标签: node.js heroku ghost-blog