我得到了以下Gruntfile.js,它只包含两个任务:第一个任务分析/生成文件,第二个任务,grunt-contrib-connect,启动web服务器:
module.exports = function(grunt) {
grunt.initConfig({
aglio: {
docs: {
files: {
'index.html': 'api.md',
},
options: {
theme: "slate"
}
}
},
connect: {
server: {
options: {
port: 9001,
hostname: 'localhost',
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-aglio');
grunt.registerTask('default', ['aglio', 'connect']);
};问题是服务器静悄悄地退出,我不知道为什么。在控制台中,如下所示:
tducin@tducin-home:~/Workspace/duck-blueprint$ grunt
Running "aglio:docs" (aglio) task
>> Written to index.html
Running "connect:server" (connect) task
Started connect web server on http://localhost:9001
Done, without errors.有人能告诉我我的connect任务配置有什么问题吗?
发布于 2015-03-08 23:24:37
你看过grunt-contrib-connect的文档了吗
根据document.You,需要将keepalive设置为true,如果希望在完成任务后保持服务器的活力。
connect: {
server: {
options: {
port: 9001,
hostname: 'localhost',
keepalive : true
}
}使服务器无限期地保持活动状态。请注意,如果启用此选项,则在此任务之后指定的任何任务都将永远不会运行。默认情况下,一旦咕噜的任务完成,web服务器就会停止。此选项将更改该行为。
https://github.com/gruntjs/grunt-contrib-connect/blob/master/README.md
https://stackoverflow.com/questions/28933018
复制相似问题