如何在Heroku上运行`grunt connect`进程
我想知道是否可以运行grunt-contrib-connect命令来为Heroku提供静态文件。
我的Grunt文件如下所示:
module.exports = function(grunt) { // Project configuration. grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), connect: { server: { options: { port: process.env.PORT || 5000, base: 'www', keepalive: true } } } }); grunt.loadNpmTasks('grunt-contrib-connect'); // Default task(s). grunt.registerTask('default', ['connect']); };
我的Procfile如下所示:
web: grunt
我的package.json看起来像这样:
{ "name": "herokoloco", "version": "0.1.1", "scripts": { "postinstall": "bower install" }, "dependencies": { "grunt": "^0.4.5", "grunt-cli": "^0.1.13", "grunt-contrib-connect": "^0.8.0", "bower": "~1.3.9" }, "engines": { "node": "0.10.x" } }
我的文件结构如下所示:
> node_modules v www index.html bower.json Gruntfile.js package.json Procfile
它使用Heroku的“工头启动networking”在本地完美工作,但在Heroku上不起作用。 我只是在我的日志中得到这个错误:
2014-10-08T21:19:23.620448 + 00:00 heroku [路由器]:在=错误代码= H14 desc =“没有web进程运行”方法= GETpath=“/”主机=屏蔽水域3266.herokuapp。 com request_id = 4d669be2-a362-4968-8349-b83b8ad0e2f6 fwd =“198.245.95.126”dyno = connect = service = status = 503 bytes =
有一次,我真的设置了一些dynos。 为此,我从Heroku项目的terminal发出了以下命令:
heroku ps:scale web=1
您可以让Heroku在完成安装后运行您想要的任何命令,方法是在Procfile中设置启动服务器的命令。 所以,像这样的:
web: ./node_modules/grunt/.bin/grunt my-grunt-command ; node app.js
应该pipe用。
确保你的软件包configuration(包括grunt-cli
)中列出了所有的grunt依赖项,确保你删除了连接configuration的hostname
部分,并使用进程端口.. ie“port:process.env.PORT || 5000 “在你连接configruation。 这对我行得通。