Tom*_*vol 4 heroku connect node.js gruntjs
我正在尝试将一个reveal.js应用程序部署到Heroku.Reveal.js通过grunt connect命令在节点上运行.该应用程序还需要ruby来动态编译资产.在本地,我可以使用运行应用程序grunt serve.
最初,由于罗盘是一个依赖grunt watch,Heroku只检测到Gemfile并假设我正在运行一个ruby应用程序.我使用nodejs自定义buildpack强制Heroku将其视为nodejs应用程序.
Procfile包含
web: grunt serve
Run Code Online (Sandbox Code Playgroud)
日志显示
2013-06-17T13:51:56.187012+00:00 heroku[router]: at=error code=H14 desc="No web processes running"
Run Code Online (Sandbox Code Playgroud)
heroku ps什么也没显示.我可以成功运行"heroku run grunt serve",我已经修改了默认的Gruntfile.js以显示接受process.env ie
connect: {
server: {
options: {
port: process.env.PORT || 8000,
base: '.'
}
}
}
Run Code Online (Sandbox Code Playgroud)
作为最后一次尝试,我尝试使用Heroku-nodejs-grunt构建包(https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt),它将在部署时运行grunt任务来编译资产.仍然没有运气,heroku logs --tail仍然显示没有进程在运行.探索heroku run显示grunt可用,并且grunt serve命令成功执行.
当开始使用新的grunt构建包时,我得到了一个错误,上面的Gruntfile.js说"进程"是未定义的.我将端口切换为0.
Web服务器将响应的端口.如果指定的端口已在使用中,则任务将失败.您可以使用特殊值0或'?' 使用系统分配的端口.
没有工作,尝试"?",没有工作(仍然没有网络进程,heroku restart没有做任何事情)
我无法弄清楚如何让Heroku使用grunt serve作为我的主要Web服务器进程!
我能够使用nodejs和expressJs使它工作.
通过跟随heroku"开始使用nodejs",我能够通过expressjs获得一个有效的webapp并在web.js中声明:
var express = require("express");
var app = express();
app.use(express.logger());
app.use("/", express.static(__dirname));
var port = process.env.PORT || 5000;
app.listen(port, function() {
console.log("Listening on " + port);
});
Run Code Online (Sandbox Code Playgroud)
有了这个,你可以从/静态地提供一切.
你有这些消息来源:https://github.com/MichaelBitard/revealjs_heroku和一个工作示例:http://murmuring-cove-4212.herokuapp.com/
| 归档时间: |
|
| 查看次数: |
1788 次 |
| 最近记录: |