QtService -or- how to run QCoreApplication as a service?
-
Hello,
my console application should be run as a service. The executable is registered as a service by the WiX Toolset which works fine. When starting the service, I get an error that it took too long to start. This is expected behaviour but how do I implement this right in Qt 5.2.1?
For 4.x there was "QtService"which is now part of Qt-Solutions.
-
I thought Qt-Solutions is just for 4.x but it also works with Qt 5.2.1.
I successfully made my app start via service. I am not sure if it works right but the service started successfully.For all who are looking for the same:
Download:
https://qt.gitorious.org/qt-solutions/qt-solutions/Unpack the archive. Copy the qtservice dir under a folder named libs (for example) inside the own project.
Add this line to .pro:
@include(libs/external/qtservice/src/qtservice.pri)@Create a new "Service" Class. I named mine "AgentService".
@#ifndef AGENTSERVICE_H
#define AGENTSERVICE_H#include <QApplication>
#include <qtservice.h>class AgentService : public QtService<QApplication>
{
public:
AgentService(int argc, char **argv);
//~AgentService();protected:
void start();
void stop();
void pause();
void resume();
void processCommand(int code);
};#endif // AGENTSERVICE_H
@After this, follow the docs inside the lib examples:
qt-solutions-qt-solutions/qtservice/doc/html/qtservice-example-interactive.htmlMaybe helpful when experimenting:
http://qt-project.org/forums/viewthread/13968 -
how you connect your app with qt service?