Forum: wxRuby restarting an application

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Fabio P. (Guest)
on 2009-03-18 10:32
(Received via mailing list)
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.
Alex F. (Guest)
on 2009-03-18 12:32
(Received via mailing list)
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
Fabio P. (Guest)
on 2009-03-18 13:58
(Received via mailing list)
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...).
Alex F. (Guest)
on 2009-03-18 14:13
(Received via mailing list)
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
Fabio P. (Guest)
on 2009-03-18 15:07
(Received via mailing list)
> 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.
This topic is locked and can not be replied to.