Application monitor

Discussion in 'Python' started by dcrespo, Nov 7, 2005.

  1. dcrespo

    dcrespo Guest

    Hi to all,

    I'd like to have an app monitor that gets rid of another app, in the
    way that if it closes unspectedly, the app monitor just wake it up one
    more time, and viceversa.

    I mean:

    Main application starts
    This one starts the App Monitor of itself. (This means that if Main
    Application closes, the App Monitor restart it)

    And viceversa means that if App Monitor closes, the Main application
    restart it.

    How can I accomplish this?

    I've been thinking in wx.SingleInstanceChecker (from wxPython GUI
    library). If it doesn't exist, then call os.system(<program_name>). But
    I don't know if there's a better way.

    Thanks

    Daniel
     
    dcrespo, Nov 7, 2005
    #1
    1. Advertising

  2. dcrespo

    Mike Meyer Guest

    "dcrespo" <> writes:
    > Main application starts
    > This one starts the App Monitor of itself. (This means that if Main
    > Application closes, the App Monitor restart it)
    >
    > And viceversa means that if App Monitor closes, the Main application
    > restart it.
    >
    > How can I accomplish this?
    >
    > I've been thinking in wx.SingleInstanceChecker (from wxPython GUI
    > library). If it doesn't exist, then call os.system(<program_name>). But
    > I don't know if there's a better way.


    "Better" depends on what your requirements are. Personally, I use init
    as an app monitor. It doesn't need monitoring - if it's dead, your
    Unix has a lot worse problems than one application being down.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Nov 7, 2005
    #2
    1. Advertising

  3. dcrespo

    dcrespo Guest

    > Personally, I use init
    > as an app monitor. It doesn't need monitoring


    What's "init"? Sorry about my ignorance.
     
    dcrespo, Nov 8, 2005
    #3
  4. dcrespo

    Mike Meyer Guest

    "dcrespo" <> writes:
    >> Personally, I use init as an app monitor. It doesn't need monitoring

    > What's "init"? Sorry about my ignorance.


    init is the first Unix process, and all other processes are descended
    from it. It is the alpha and the omega of Unix processes. Uh, wait a
    second - I'm having biblical flashes here. Let's try again:

    init is the first process started when a Unix system boots, and is
    hand crafted by the boot process. Every other process on the system is
    started by a fork (or a variant) system call, and are descendants of
    init. Part of it's job is starting the various server processes on the
    system that are appropriate for the system state. It notices when they
    exit, and restarts them. On timesharing systems, it will start a login
    process on every terminal, which would then exec it's way into a user
    shell, which would exit - which init would notice, and launch another
    login on that terminal. If init is dead, your Unix system is in a bad
    way.

    You can use this on modern Unix systems. You add an entry to init's
    config file (/etc/inittab on SysV-like systems, and /etc/ttys on
    BSD-derived systems), and init will launch a process for that
    entry. If the process ever exits, init will launch it again.

    For instance, I launch an ssh client to keep a couple of TCP tunnels
    open to my ISPs server so I can access services that aren't available
    from my current location. I run that via init. No need to worry about
    hardening the ssh client, or writing a wrapper around it, or anny such
    thing. init deals with all of that for me.

    <mike
    --
    Mike Meyer <> http://www.mired.org/home/mwm/
    Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
     
    Mike Meyer, Nov 9, 2005
    #4
  5. dcrespo

    Magnus Lycka Guest

    dcrespo wrote:
    > Hi to all,
    >
    > I'd like to have an app monitor that gets rid of another app, in the
    > way that if it closes unspectedly, the app monitor just wake it up one
    > more time, and viceversa.


    Twisted contains such a thing. I think it's called twisted.runner,
    and no, it's not just for keeping Twisted processes running.
     
    Magnus Lycka, Nov 9, 2005
    #5
  6. Many thanks for your answers.

    Respect Init, I need a cross platform solution. Most of times my system
    will run in Win98 and XP (more on XP than 98)

    Respect Twisted... Mmm... I already started with another networking
    library (TCPServer and SimpleXMLRPCServer), and I wouldn't like to mix
    things because I don't know so much about those libraries. I know that
    Twisted can do what I already have. But replacing it can be a hard
    task. So I would like to have a function like FindPID(exename) --> PID,
    or something more generic that could tell me the PID of a running
    program, and kill him in a certain moment.

    Daniel
     
    Daniel Crespo, Nov 9, 2005
    #6
  7. dcrespo

    Magnus Lycka Guest

    Daniel Crespo wrote:
    > Respect Twisted... Mmm... I already started with another networking
    > library (TCPServer and SimpleXMLRPCServer), and I wouldn't like to mix
    > things because I don't know so much about those libraries. I know that
    > Twisted can do what I already have. But replacing it can be a hard
    > task. So I would like to have a function like FindPID(exename) --> PID,
    > or something more generic that could tell me the PID of a running
    > program, and kill him in a certain moment.


    You *could* use twisted.runner for process control even if you
    don't use twisted for your networking code. It does seem like
    a funny thing to do, but there's nothing stopping you from doing
    that. The example code in twisted.runner starts up a few shell
    scripts that die on their own accord, and make sure they get
    restarted, so it doesn't rely on twisted being used in the
    processes it controls.
     
    Magnus Lycka, Nov 9, 2005
    #7
  8. Magnus Lycka wrote:
    > You *could* use twisted.runner for process control even if you
    > don't use twisted for your networking code. It does seem like
    > a funny thing to do, but there's nothing stopping you from doing
    > that. The example code in twisted.runner starts up a few shell
    > scripts that die on their own accord, and make sure they get
    > restarted, so it doesn't rely on twisted being used in the
    > processes it controls.


    Ok. I'll take a look. Thank you very much! :)

    Daniel
     
    Daniel Crespo, Nov 9, 2005
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ravi Ambros Wallau
    Replies:
    2
    Views:
    3,978
    Ravi Ambros Wallau
    Jan 13, 2006
  2. Replies:
    4
    Views:
    349
    Tim Golden
    Feb 23, 2007
  3. Replies:
    0
    Views:
    619
  4. ScottZ
    Replies:
    2
    Views:
    394
    Jorgen Grahn
    Nov 2, 2008
  5. mike

    JAVA web site monitor application

    mike, Apr 16, 2009, in forum: Javascript
    Replies:
    4
    Views:
    166
    Jorge
    Apr 17, 2009
Loading...

Share This Page