Failing hard and fast during app startup

I’d like my Meteor app to check on startup if there’s an extant file called /usr/local/bin/myprog and die immediately (really die - go right back to the command prompt) if it doesn’t find that dependency and reveal nothing about this error to clients. I can make Meteor die, but if I HTTP GET to the standard port (for example http://localhost:3000), I get a stack trace and anything logged to standard error. Can I suppress this? Like, kill my Meteor server and the proxy thing too?

throwing anything and process.exit(1) both seem to leave the proxy running.

how about writing shell script to check if that file exists and start meteor.

#!/bin/bash file="/usr/local/bin/myprog" if [ -f "$file" ] then echo "no found or empty" else meteor fi

Not a bad idea, but this is actually a mup-deployed app and I don’t know a clean way to inject a script like this without patching mup.

I’d really rather do something right in the app’s JavaScript code, if possible.

i didnt read properly lols.

in this case

  • have a reactive variable that watchs a file/folder
  • based on variable then you can stop meteor+nginx

Stop meteor+nginx how, exactly?

you can get he PID of nginx with this shell command pidof nginx and kill it with kill [signal] PID . you can use shelljs to write your commands directly in JavaScript.

Thanks for the suggestions, guys.

It’s a bummer that–in dev–there’s no way to kill the proxy (or whatever it is that keeps running in front of a crashing app).

But, rejoice! I was wrong about what happens for mup-deployed apps. On the server, throw anywhere in the Meteor app does exactly what I want: prevents mup from successfully deploying the app.