Restarting an application


#1

Hi folks,

i was wondering if is there any way to automatically restart wxruby
application.

A sample code would be appreciated.

thank you all.

bio.


#2

Fabio P. wrote:

i was wondering if is there any way to automatically restart wxruby
application.

Can you explain a bit more what you mean? Under what circumstances would
the application be ending? If it’s an exception, rescue it at the most
appropriate level.

You can’t enter Wx::App’s main loop more than once in a script, but you
can have no visible frames/dialogs. If you don’t want to end the
application, hide() the frame, rather than close().

a


#3

Hi Alex,

Can you explain a bit more what you mean? Under what circumstances would
the

application be ending? If it’s an exception, rescue it at the most
appropriate level.

basically the idea i to upgrade the application via network and, after
the
upgrade process, restart to reload everything (xrc-layouts, models,
configurations…).


#4

This works for me on OS X:

Wx::App.run do
def self.on_exit
exec(“ruby #$0”)
end

end

thank you, i’ll have a go with your solution

If it’s an open app, I’d be interested to hear about/see examples of code
updating over net whenever you’re ready.

It’s just a vague idea, i don’t know yet how to implement it and tools
to
use, suggestions are wellcome.

cheers,

bio.


#5

Fabio P. wrote:

basically the idea i to upgrade the application via network and,
after the upgrade process, restart to reload everything (xrc-layouts,
models, configurations…).

In that case I think the best thing would be to start a fresh ruby
process, otherwise you will have all the old models etc already loaded.

This works for me on OS X:

Wx::App.run do
def self.on_exit
exec(“ruby #$0”)
end

end

This assumes the environment’s ruby is the right one to start the app.
Note that you’ll want to have your editor handy to comment out the
restart else you’ll end up in a permanent loop. In your case, you’ll
want to wrap the exec in some sort of conditional which checks for
restart after upgrade.

If it’s an open app, I’d be interested to hear about/see examples of
code updating over net whenever you’re ready.

alex