add debug message before sleeping
if running under debugging and using stdout, then run unbuffered
added run dir
use SIGTERM rather than SIGQUIT