After hours of debugging, I finally isolated why my web app was crashing on Windows. An NPM dependency is sometimes logging messages with console.error, and this seems to have different behaviours on OSX & Windows when running the Foreman + Nodemon combo.
Maybe someone with more knowledge of these tools can help shed some light on this? Here's a simple app to illustrate it:
app.js
console.log('1');
console.error('2');
console.log('3');
Running nodemon --exec node app.js works fine on both OSX & Windows 7, and gives the expected output:
18 Feb 23:56:25 - [nodemon] v0.6.23
18 Feb 23:56:26 - [nodemon] watching: C:\project
18 Feb 23:56:26 - [nodemon] starting `node app.js`
1
2
3
18 Feb 23:56:26 - [nodemon] clean exit - waiting for changes before restart
Now, wrapping the call using Foreman and a Procfile, it looks like this:
# Procfile
app: nodemon --exec node app.js
On OSX:
> foreman start
23:59:12 app.1 | started with pid 69229
23:59:12 app.1 | 18 Feb 23:59:12 - [nodemon] v0.7.2
23:59:12 app.1 | 18 Feb 23:59:12 - [nodemon] watching: /project
23:59:12 app.1 | 18 Feb 23:59:12 - [nodemon] starting `node app.js`
23:59:12 app.1 | 1
23:59:12 app.1 | 2
23:59:12 app.1 | 3
23:59:12 app.1 | 18 Feb 23:59:12 - [nodemon] clean exit - waiting for changes before restart
On Windows:
> foreman start
23:59:40 app.1 | started with pid 2624
23:59:40 app.1 | 18 Feb 23:59:40 - [nodemon] v0.7.2
23:59:40 app.1 | 18 Feb 23:59:40 - [nodemon] watching: C:\project
23:59:40 app.1 | 18 Feb 23:59:40 - [nodemon] starting `node app.js`
23:59:40 app.1 | 1
23:59:40 app.1 | 18 Feb 23:59:40 - [nodemon] exception in nodemon killing node
23:59:40 app.1 | exited with code 3
23:59:40 system | sending SIGKILL to all processes
The app simply crashes, with no recovery, and then Foreman kills any other process declared in the Procfile.
Any ideas will be appreciated!
note: I tried a different version of nodemon on Windows (6.2.3) with the same results