heroku desc部署错误=“没有运行Web进程”
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了heroku desc部署错误=“没有运行Web进程”相关的知识,希望对你有一定的参考价值。
我正在将我的应用程序部署到heroku中,它是用Node.js编写的,主要脚本是main.js看起来像这样
var fs = require('fs');
var file = fs.readFileSync('count.json');
var Words = JSON.parse(file);
const express = require('express');
const app = express();
app.listen(process.env.PORT || 3000, () => console.log('we are listeining'));
app.use(express.static('public'));
app.use(express.json( limit : '1mb' ));
app.get('/add/:word', addWord);
function addWord(request, response)
var data = request.params;
var word = data.word;
var reply;
var found = false;
for (i = 0; i < Words.length; i++)
if (Words[i].type == word)
Words[i].count++;
found = true;
break;
if (!found)
Words.push("type": word , "count": 1);
var x = JSON.stringify(Words, null, 2);
fs.writeFile('count.json', x, finished);
function finished()
console.log('Yay')
/*
console.log(Words[word]); */
/* response.send(reply); */
我也已经将Procfile部署为
worker: node main.js
但是仍然有这个问题,这是heroku的日志
2020-05-09T22:56:21.244885+00:00 heroku[worker.1]: State changed from starting to up
2020-05-09T22:56:24.487998+00:00 app[worker.1]: we are listeining
2020-05-09T22:56:34.768703+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=bss-ticketmaker.herokuapp.com request_id=7e7b9f8d-6ffb-4d93-9691-c9024f1a576a fwd="156.205.74.140" dyno= connect= service= status=503 bytes= protocol=https
2020-05-09T22:56:36.265759+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=bss-ticketmaker.herokuapp.com request_id=8d817eeb-c233-44b0-ba76-be54907533a6 fwd="156.205.74.140" dyno= connect= service= status=503 bytes= protocol=https
答案
您正在运行Web服务器,因此在Procfile
中设置为web
而不是worker
。
web: node main.js
Heroku将HTTP请求路由到以web
名称开头的进程。
以上是关于heroku desc部署错误=“没有运行Web进程”的主要内容,如果未能解决你的问题,请参考以下文章
Heroku 错误 at=error code=H14 desc="No web processes running" method=GET path="/"
Heroku 崩溃错误:heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/fa