我想知道是否可以運行grunt-contrib-connect命令以便爲Heroku提供靜態文件。如何在Heroku上運行`grunt connect`進程
我咕嚕文件看起來像這樣:
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的「工頭啓動網站」在本地完美工作,但在Heroku上無法使用。我剛剛得到這個錯誤在我的日誌:
2014-10-08T21:19:23.620448 + 00:00的Heroku [路由器]:在=錯誤代碼= H14 DESC = 「沒有Web進程中運行」 的方法= GET path =「/」 host = shielded-waters-3266.herokuapp.com request_id = 4d669be2-a362-4968-8349-b83b8ad0e2f6 fwd =「198.245.95.126」 dyno = connect = service = status = 503 bytes =
完全瞭解你,但我嘗試過並沒有工作。我不想要的是使用nodejs服務器,我想在'Procfile'中的'web'任務上運行'grunt connect',但它不起作用。 – kevinwolf 2013-05-13 01:41:52
爲了完成這項工作,您可能需要獲取PORT環境變量並找出如何將其添加爲grunt-contrib-connect的選項。 – dankohn 2013-05-13 03:18:35
我已經這樣做了,在'grunt-contrib-connect'選項中我已經把'port:process.env.PORT || 3000',並在Heroku日誌中說Heroku分配了端口,但仍然沒有工作。 – kevinwolf 2013-05-13 05:19:15