Reputation: 29
i am deploying my app to heroku it is written in Node.js the main script is main.js looks like this
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); */
}
i am also have deployed the Procfile to be
worker: node main.js
but still having this problem and this is the logs of 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
Upvotes: 0
Views: 64
Reputation: 12542
You are running a web server so in the Procfile
set web
instead of worker
.
web: node main.js
Heroku will route HTTP requests to processes started with the web
name.
Upvotes: 2