bounce icon indicating copy to clipboard operation
bounce copied to clipboard

Bounce should stay running after crash

Open zzen opened this issue 15 years ago • 11 comments

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.

zzen avatar Sep 06 '10 01:09 zzen

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 ?

weepy avatar Sep 06 '10 08:09 weepy

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.

zzen avatar Sep 06 '10 09:09 zzen

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 ?

weepy avatar Sep 06 '10 19:09 weepy

Or would

bounce -g -r -w "node -nodeOpt lib/server.js"

be a better approach ?

weepy avatar Sep 07 '10 08:09 weepy

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"

zzen avatar Sep 07 '10 13:09 zzen

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...

zzen avatar Sep 07 '10 13:09 zzen

soz - i don't quite follow your idea -- would you mind explaining it again -- thanks

weepy avatar Sep 07 '10 14:09 weepy

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.js works identically
  • Calling bounce_p -nodeOpt lib/server.js calls 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 with node and node_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).

zzen avatar Sep 07 '10 15:09 zzen

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?

weepy avatar Sep 08 '10 11:09 weepy

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.

zzen avatar Sep 08 '10 15:09 zzen

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.

weepy avatar Sep 09 '10 14:09 weepy