Application monitor

D

dcrespo

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
 
M

Mike Meyer

dcrespo said:
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
 
M

Mike Meyer

dcrespo said:
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
 
M

Magnus Lycka

dcrespo said:
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.
 
D

Daniel Crespo

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
 
M

Magnus Lycka

Daniel said:
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.
 
D

Daniel Crespo

Magnus said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top