Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, January 2007
Background daemon in QT.


Message 1 in thread

I need to program a QT application that will start at System boot. I've
got it running normally but then decided to try the system boot part and
found that Duh it dies if X isn't running. Is there a way to check to
see if X is running beforehand instead of just creating a QApp and
having the program blow up on me. 

I'd love for there to be a way for the program to survive if X windows
shuts down once the application is up. Instead of it suddenly closing
the x client and killing the program.

-----Original Message-----
From: Nox PasNox [mailto:pasnox@xxxxxxxxx] 
Sent: Wednesday, January 17, 2007 4:05 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: RE: Single Application Instance - Inter Application Messaging

Thanks about this methods that are not bad ! 
I will try to implement this methods.

Cheers, P@sNox,

Scott Aron Bloom wrote:

> besides that this has nothing to do with QT... Ill give you some
feedback
> in the form of questions :-)
>  
> Are the two instances always on the same machine?
> How do the two instances know about each other?
> How should they handle exceptions to the communication protocol?
> 
> I have used TCP sockets for this, I have used a lightweight WWW server
for
> this, I have used files on the local filesystem.  I no longer create
my
> own protocol, and rather simply use XML for it, but all these methods
> could use QT or not.
>  
> Scott
>  
> 
> ________________________________
> 
> From: Nox PasNox [mailto:pasnox@xxxxxxxxx]
> Sent: Wed 1/17/2007 8:51 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Single Application Instance - Inter Application Messaging
> 
> 
> 
> Hi,
> 
> Hi know that this is a faq, homewer i want to complete this faq with
> another request :
> 
> * What is the best way for doing a single instance application (
answers
> from the newsgroups don't seem to be the way i want to )
> * How i can do to make my 2 instance communicate ? In fact, i need to
ask
> to first instance to open the file request by the second.
> 
> Thanks, P@sNox,
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and
information:
> http://lists.trolltech.com/qt-interest/
> 
> 
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and
information:
> http://lists.trolltech.com/qt-interest/

-- 
 [ signature omitted ] 

Message 2 in thread

On 17.01.07 17:14:11, Allen, Matthew wrote:
> I need to program a QT application that will start at System boot. I've
> got it running normally but then decided to try the system boot part and
> found that Duh it dies if X isn't running. Is there a way to check to
> see if X is running beforehand instead of just creating a QApp and
> having the program blow up on me. 

Sure, for example you could check for X in the process list in your init
script. Even better would be is your Qt app doesn't need X11, then you
could try Qt4 which allows Qt programs to run without X11 by using only
stuff from QtCore.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

You don't say what system this, but I presume that it's Linux. If so,
you can run it as a script that is initiated only in run level 6. Look
in /etc/rc6.d. There are a bunch of scripts in there. The ones that
start with K run at start up, the ones with S at shutdown. The number is
the order in which they run. X is only started in run level 6. Not sure
where you can get more info on this, but it's fairly obvious how it
works. 


William R Volz,  Staff Research Scientist
Emerging Technology, Strategy & Consulting Team
Technical Computing Technology Department

Chevron Corporation
Energy Technology Company
#19094A
1500 Louisiana
Houston, TX, 77002
Tel 832 854 6738 Fax 832 854 6721

><mailto:bill.volz@xxxxxxxxxxx>
>This message may contain confidential information that is proprietary
to ChevronTexaco and is intended only for the use of the parties to whom
it is addressed. If you are not an intended recipient, you are hereby
notified that any disclosure, copying, distribution or use of any
information in this message is strictly prohibited. If you have received
this message in error, please notify me immediately at the telephone
number noted above

-----Original Message-----
From: Allen, Matthew [mailto:allenm@xxxxxxxxxxxxxxxxxxxxxx] 
Sent: Wednesday, January 17, 2007 4:14 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Background daemon in QT.

I need to program a QT application that will start at System boot. I've
got it running normally but then decided to try the system boot part and
found that Duh it dies if X isn't running. Is there a way to check to
see if X is running beforehand instead of just creating a QApp and
having the program blow up on me. 

I'd love for there to be a way for the program to survive if X windows
shuts down once the application is up. Instead of it suddenly closing
the x client and killing the program.

-----Original Message-----
From: Nox PasNox [mailto:pasnox@xxxxxxxxx]
Sent: Wednesday, January 17, 2007 4:05 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: RE: Single Application Instance - Inter Application Messaging

Thanks about this methods that are not bad ! 
I will try to implement this methods.

Cheers, P@sNox,

Scott Aron Bloom wrote:

> besides that this has nothing to do with QT... Ill give you some
feedback
> in the form of questions :-)
>  
> Are the two instances always on the same machine?
> How do the two instances know about each other?
> How should they handle exceptions to the communication protocol?
> 
> I have used TCP sockets for this, I have used a lightweight WWW server
for
> this, I have used files on the local filesystem.  I no longer create
my
> own protocol, and rather simply use XML for it, but all these methods 
> could use QT or not.
>  
> Scott
>  
> 
> ________________________________
> 
> From: Nox PasNox [mailto:pasnox@xxxxxxxxx]
> Sent: Wed 1/17/2007 8:51 AM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Single Application Instance - Inter Application Messaging
> 
> 
> 
> Hi,
> 
> Hi know that this is a faq, homewer i want to complete this faq with 
> another request :
> 
> * What is the best way for doing a single instance application (
answers
> from the newsgroups don't seem to be the way i want to )
> * How i can do to make my 2 instance communicate ? In fact, i need to
ask
> to first instance to open the file request by the second.
> 
> Thanks, P@sNox,
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with

> "unsubscribe" in the subject or the body. List archive and
information:
> http://lists.trolltech.com/qt-interest/
> 
> 
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with

> "unsubscribe" in the subject or the body. List archive and
information:
> http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ] 

Message 4 in thread

On Thursday 18 January 2007 00:38, Volz, Bill (WRVO) (Bill.Volz) wrote:
> You don't say what system this, but I presume that it's Linux. If so,
> you can run it as a script that is initiated only in run level 6. Look
> in /etc/rc6.d. There are a bunch of scripts in there. The ones that
> start with K run at start up, the ones with S at shutdown. The number is
> the order in which they run. X is only started in run level 6. Not sure
> where you can get more info on this, but it's fairly obvious how it
> works.
>

I personally would take runlevel 5 (runlevel 6 is the reboot level... )

Kind regards

-- 
 [ signature omitted ] 

Message 5 in thread

Allen, Matthew schrieb:
> I need to program a QT application that will start at System boot. I've
> got it running normally but then decided to try the system boot part and

Just in case you're a paying customer and hence are using the commercial
version: there are "Qt solutions" available on Trolltech's website,
among them "Qt service" which implements exactly what you're looking for
(a service on Windows, a daemon on Unix, installable so it automatically
runs at boot time). The "Qt solutions" cost a little bit extra though.

I also have a "service" based on QtService implemented, using only
QtCore as base, so in theory it should also run without X11 (have not
tried yet so far, since I'm focusing on Windows right now).

Cheers, Oliver

--
 [ signature omitted ] 

Message 6 in thread

My program uses X but only when it needs to interact with a user. Users
may come and go but if something happens with the daemon it's supposed
to alert the current user to the issue. Or if there is no current user
to log the report.

-----Original Message-----
From: Andreas Pakulat [mailto:apaku@xxxxxx] 
Sent: Wednesday, January 17, 2007 5:41 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Background daemon in QT.

On 17.01.07 17:14:11, Allen, Matthew wrote:
> I need to program a QT application that will start at System boot.
I've
> got it running normally but then decided to try the system boot part
and
> found that Duh it dies if X isn't running. Is there a way to check to
> see if X is running beforehand instead of just creating a QApp and
> having the program blow up on me. 

Sure, for example you could check for X in the process list in your init
script. Even better would be is your Qt app doesn't need X11, then you
could try Qt4 which allows Qt programs to run without X11 by using only
stuff from QtCore.

Andreas

-- 
 [ signature omitted ] 

Message 7 in thread

On Thursday 18. January 2007 22:19, Allen, Matthew wrote:
> My program uses X but only when it needs to interact with a user. Users
> may come and go but if something happens with the daemon it's supposed
> to alert the current user to the issue. Or if there is no current user
> to log the report.

Then I would split it into two programs. One is the deamon that run without X. 
This can be started without having X to be active. The other is a User-IF 
program that is called when needed.

-- 
 [ signature omitted ] 

Message 8 in thread

Am Freitag, 19. Januar 2007 08:14 schrieb Reinhardt Behm:
> On Thursday 18. January 2007 22:19, Allen, Matthew wrote:
> > My program uses X but only when it needs to interact with a user. Users
> > may come and go but if something happens with the daemon it's supposed
> > to alert the current user to the issue. Or if there is no current user
> > to log the report.
>
> Then I would split it into two programs. One is the deamon that run without
> X. This can be started without having X to be active. The other is a
> User-IF program that is called when needed.

I want to sign this message and would also vote for splitting the program.  
But it would be a good method to write both programs with qt, so you can use 
the same communications mechanism between the programs for both.

Then of course you have to create one qt process which runs without a gui and 
therefore doesn't need one, when you give this parameter to either

QApplication ( int & argc, char ** argv,
		bool GUIenabled )  /*GUIenabled=false*/

or

QApplication ( int & argc, char ** argv,
		Type type ) /* type = QApplication::Tty */

The second one should do the same as the first one ?!
See the Qt documentation how to use it.  There you also find an example how to 
start the "gui version" and the "non gui version" of your program.

Through such a switch you could run one program in daemon and user interaction 
mode.  But I would downscale the non gui daemon process a bit.  The result 
again is to write two programs.

bye ingo

-- 
 [ signature omitted ]