RendleLabs

Running DNX apps with nodemon

Very quick, as much a note for myself as anything else.

There’s a Node package called nodemon which monitors files and restarts processes; it’s primarily used to watch .js files and restart Node applications when they change.

You can use it with any file extensions and commands, though, which means you can use it to monitor .cs files and restart DNX applications when they change. It also stops Kestrel when you (reflexively) hit Ctrl-C, which often makes Kestrel on its own hang.

I’ve set up this Bash function to do this on my machine:

DNX_DEFAULT_DIR=.
DNXMON_CMD=kestrel
dnxmon () {
  nodemon -e cs,json -x "dnx ${1-$DNX_DEFAULT_DIR} ${DNXMON_CMD}"
}

I used to use an alias, but it wouldn’t let me change the directory passed to dnx and I’ve been finding that useful. If you want, you can also change the DNXMON_CMD variable to run a command other than kestrel.

markrendle

markrendle

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.