Problem in execution of QtService
Hi,
I am using QtService to upload some data into the database. Installation and starting the service works without giving any error. But the logic of uploading the data which is present in the start() method is not happening.
But, If I ran the same service by giving '-e' as argument, the uploading of data into database happens and the logic just works fine.
But the former, installation and start of a service ideally should do the work as expected. Is there any thing I forgot to set such the service is not working??:confused:
Re: Problem in execution of QtService
I have tried using logMessage(...) to log the event to see whether the control comes to start() method. I checked in windows Event Viewer and there is a message logged confirming the same.
Now other component I have used is QTimer and have set the Interval to 1 minute. And the timeout is also connected. But the logic of uploading into the DB is not happening.
Re: Problem in execution of QtService
Adding to it!! I have got one more warning message while debugging..
QTimer::StartTimer can only be used with threads started with QThread..
My class declaration looks like this,
Code:
class CUploadService
:public QObject,
public QtService<QCoreApplication>
It's a application type not a library. Is that warning message any of the help for me to fix this issue ? Any help guys..
Re: Problem in execution of QtService
At last, the problem solved. The problem lies in the QDir:homePath() while getting the path of the file which has the content for upload. The behaviour is like this,
Installing a service:
MyService -i
QDir::homePath() => D:/Documents and Settings/MyProfileName/
Starting a service:
MyService -s
QDir::homePath() => C:/WINDOWS/system32/config/systemprofile/
Stopping a service:
MyService -t
QDir::homePath() => C:/WINDOWS/system32/config/systemprofile/
Uninstalling a service:
MyService -u
QDir::homePath() => D:/Documents and Settings/MyProfileName/
The same method returns different location for homePath() if it is service. I don't understand this behaviour of the method. Is this a bug on part of QDir::homePath??
Re: Problem in execution of QtService
Hi nikhilqt,
I've your same problem, I've a service that install itself, but seems that don't call start method. When I start the service with -e option all go fine.
I don't understad where's the problem.
If you found the problem please share it.
Thanks
Re: Problem in execution of QtService
Quote:
Originally Posted by
maluedo
I've a service that install itself, but seems that don't call start method. When I start the service with -e option all go fine. I don't understad where's the problem.
Thanks
As I mentioned in the earlier post, the problem got solved. The start method was indeed calling but there was a problem in behaviour of QDir::homePath(). Refer my earlier post for the same.
I used lots of QtService::logMessage(...) method to log messages to unearth the problem. You can use this method calls in QtService::start() method and all other methods to check whether the control is coming and behaving as per your expectation.
PS: Check the messages in EventViewer in windows os.
Re: Problem in execution of QtService
Thanks for your support,
I done as you mentioned, I found where's the problem; in the start() I've a class that open through ODBC a visual fox pro database, this open fails!. If I start the service with "-e" flag all go fine.
I don't understand why. Do you have some tips for me?
Re: Problem in execution of QtService
Found the problem; I was configured the DSN as user and not as system. :-)