Bounce should stay running after crash
It's great that when developing, bounce will keep my latest version running so I can just reload the browser to see changes. But people make mistakes, and when syntax errors prevent the file to run, bounce dies together with the node child instance.
This means that when developing and when bugs occur, I need to keep re-running my bounce all the time and it's pretty much back to where I was without bounce.
I think better behavior would be to print the failure to console but stay running, waiting for the file to be changes/fixed.
Change attached.
I had it like this first. I suppose the only downside is that you don't always know if it's crashed. I suppose we could have a growl notification ?
Growl would be great. Another option (if there are ambiguities) would be to provide this behavior as a command-line switch?
My usecase is: if I'm editing some code, saving from time to time during the process, I have my jslint validator in Textmate already. I don't need bounce to tell me I'm missing a semicolon - I got that solved in my editor workflow. And I certainly don't want bounce to exit - thus forcing me to run it again.
gotcha - so perhaps the command-line switches could work like:
bounce -nodeOpt lib/servers -- -g -r -w src
where the switches after a final -- go to bounce with the bit before the -- going to node ?
Or would
bounce -g -r -w "node -nodeOpt lib/server.js"
be a better approach ?
Or a third option would be to have in /usr/local/bin a symlink to bounce executable and check $0 on runtime:
bounce_p -nodeOpt lib/server.js
or perhaps check process.env.BOUNCE_PERSIST:
export BOUNCE_PERSIST=true && bounce -nodeOpt lib/server.js
I have to say I quite like the usability of "replace node by bounce"
Regarding the symlink option, I was thinking of helping you create some npm / better build scripts anyway so the symlink could be setup as part of that...
soz - i don't quite follow your idea -- would you mind explaining it again -- thanks
Option 1:
- During install process, we install bounce into /usr/local/bin and then install symlink
ln -s /usr/local/bin/bounce_p /usr/local/bin/bounce - Calling bounce in identical syntax as now
bounce -nodeOpt lib/server.jsworks identically - Calling
bounce_p -nodeOpt lib/server.jscalls through the symlink the same script, but the name of the script called on command-line can be determined in node at runtime and the persistent behavior can be triggered. A similar thing works withnodeandnode_g
Option 2:
Use environment variable to switch between the behaviors. If process.env.BOUNCE_PERSIST is set to 1, we'll trigger the persistent behavior. A similar thing works in Sencha Connect (app.configure can configure production and development configuration separately, and the app senses where it runs based on environment).
how about my first suggestion where the bounce options are placed after a --:
bounce -nodeOpt lib/server.js -- -g -r -w src
It seems fairly simple?
Personally, I'd prefer any other option. I like being able to switch between node and bounce commands without changing anything else on the command-line. But obviously we can support multiple of these. If I get time this week, I'll try to implement at least Option 2 and send you a patch. You can work on the -- option if you prefer it.
I think if we have my -- idea coupled with some default bounce params
export BOUNCE_PARAMS='-w -g -r' && bounce ...etc
we'll cover all the bases.