I am running a NodeJS http express server on my fly machine. Every time Fly sends SIGINT, it does not seem to make it to my app. I am trying to ‘catch’ the SIGINT in my app.js like this. However, nothing gets printed and I get [warn]Virtual machine exited abruptly
Any idea why this may be? Here is my repo which also contains the fly.toml and relevant www and app.js files. My app runs with NODE_ENV=production node ./bin/www
Line 29 in your Dockerfile is the cause. Switch from npm start to the CMD ["node", "./bin/www"] and that should do it. I believe NODE_ENV is already set in the machine given that it’s set in the Dockerfile
I updated line 39 to now be CMD ["node", "./bin/www"] which completely fixed my issue! Thank you so much, I’ve been really struggling trying to get this working. I appreciate your help tremendously. Not sure why this dockerfile was incorrect… It was auto-generated with fly launch. I did try creating a new test app using fly launch again and it looks like it generated a dockerFile that was using the format you suggested. I guess there’s been an update from Fly on how dockerFiles get generated…
I do have one more small issue now. I see it even with a very simple helloWorld express JS app. I see this error when shutting machine down: WARN could not unmount /rootfs: EINVAL: Invalid argument
Any idea what may be causing that or is it an ongoing Fly issue I should ignore?
That’s the default generated by flyctl. As with any automated generation tool, cross check that what it gives you what you really want. They’re good at providing defaults that most apps need but may easily get out of date. And you can switch to Node 22 for your base image to utilise more features and performance improvements