Foreman, from the Heroku Toolbelt, exits with Error: write EINVAL every time
Asked Answered
L

2

6

Following Heroku's Getting Started tutorial has been much more frustrating than I expected it to be. What I have right now is probably a config problem, and it can probably be solved in less than 10 clicks, but I don't know what those clicks are and it's driving me up the wall.

Foreman won't start. I have no experience with Ruby, or Heroku, or Foreman, and barely any experience with web programming, so I have absolutely no idea what's happening here. Here's the error message I get, running Windows 7 64 bit:

C:\Users\___________\hello_world_basics>foreman start
09:40:17 web.1  | started with pid 2408
09:40:18 web.1  | Listening on 5000
09:40:18 web.1  |
09:40:18 web.1  | Error: write EINVAL
09:40:18 web.1  |     at errnoException (net.js:904:11)
09:40:18 web.1  |     at Socket._write (net.js:645:26)
09:40:18 web.1  |     at doWrite (_stream_writable.js:226:10)
09:40:18 web.1  |     at writeOrBuffer (_stream_writable.js:216:5)
09:40:18 web.1  |     at Socket.Writable.write (_stream_writable.js:183:11)
09:40:18 web.1  |     at Socket.write (net.js:615:40)
09:40:18 web.1  |     at Console.log (console.js:53:16)
09:40:18 web.1  |     at Server.<anonymous> (C:\Users\___________\hello_world_basics\web.js:14:11)
09:40:18 web.1  |     at Server.g (events.js:180:16)
09:40:18 web.1  | exited with code 8
09:40:18 system | sending SIGKILL to all processes
09:40:18        |     at Server.EventEmitter.emit (events.js:92:17)

Google is evading me. I can't find the answer with any searching. I've restarted, reinstalled, rewritten, recopied, reread, etc. and I can't find a solution. My code exactly mirrors the code on the Getting Started page linked above, which I'll paste here for convenience:

Procfile:

web: node web.js

web.js

var express = require("express");
var logfmt = require("logfmt");
var app = express();

app.use(logfmt.requestLogger());

app.get('/', function(req, res) {
  res.send('Hello World!');
});

var port = Number(process.env.PORT || 5000);
app.listen(port, function() {
  console.log("Listening on " + port);
});

packge.json

{
  "name": "hello_world_basics",
  "version": "0.0.0",
  "description": "A simple hello world app.",
  "main": "web.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "[email protected]:hello_world_basics.git"
  },
  "keywords": [
    "twitter",
    "quality",
    "bestof"
  ],
  "author": "Lincoln Bergeson",
  "license": "ISC",
  "dependencies": {
    "logfmt": "^1.1.2",
    "express": "^4.4.3"
  }
}

Again, I followed everything exactly as I should have on the Getting Started page, but foreman refuses to start. What's going on here?

Larine answered 19/6, 2014 at 15:55 Comment(0)
L
0

This isn't a very good solution, but I have figured out how to make foreman work. The instructions on the Getting Started page must be broken or out of date. Here's how I got foreman to work:

  1. Keep package.json the same.
  2. Delete web.js
  3. Create a standard Express app by running express my_app_name at the command line.
  4. Create an index.js file that imports Express's app.js and starts a server.
  5. Configure the Procfile to point to index.js.
  6. Run foreman start and it should work.

I don't know why this works and the previous steps did not. Good luck, future searchers, in your quest.

Larine answered 24/6, 2014 at 16:13 Comment(0)
L
8

Here's a similar Stackoverflow Q/A:
Node.js Expres.js Heroku Toolbelt >Foreman Start - Error: write EINVAL

I had the same issues as Jek. I was using express 4.4.4. I downgraded express 3.2.6 and it worked, but I shouldn't be forced to use an older version of express just because foreman doesn't support it.

I tried node-foreman. And it worked for me. I followed the instructions that included these steps:

  1. npm install -g foreman
  2. nf start

I would like to know if anyone has additional suggestions.

Lookin answered 5/7, 2014 at 0:47 Comment(1)
I'm on Windows 7 and had issues also; foreman would start, but would crash on delivering a webpage. so at first I uninstalled both git and heroku, rebooted, then reinstalled the heroku toolbelt, then downloaded the latest version of git *Git-1.9.5-preview20150319) and still ran into the same issues. installing the npm foreman package and using it to start it, solved the issue.Territerrible
L
0

This isn't a very good solution, but I have figured out how to make foreman work. The instructions on the Getting Started page must be broken or out of date. Here's how I got foreman to work:

  1. Keep package.json the same.
  2. Delete web.js
  3. Create a standard Express app by running express my_app_name at the command line.
  4. Create an index.js file that imports Express's app.js and starts a server.
  5. Configure the Procfile to point to index.js.
  6. Run foreman start and it should work.

I don't know why this works and the previous steps did not. Good luck, future searchers, in your quest.

Larine answered 24/6, 2014 at 16:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.