this catches exceptions where grunt worked but restartServer didn't. Should you perhaps wrap just the require in a try catch then check for a non-null grunt variable?