Qt-solutions Archive, March 2008
Problems starting a QtService
Message 1 in thread
Hello,
I'm using QtService 2.4 and Qt 4.3.2 to create a server to run under
Linux and windows 2000/XP. I'm having difficulty starting the server
and/or getting it to disconnect from the running process.
I tried the following to start the server as shown in the
QtServiceController documentation:
int main (int argc, char** argv)
{
XLMService service(argc, argv); // inherits QtService
service.setStartupType(QtServiceController::ManualStartup);
QString serviceFilePath;
QtServiceController controller(service.serviceName());
if (controller.install(serviceFilePath))
controller.start();
if (controller.isRunning())
messages.misc("Server is running...\n");
return 1;
}
The server never starts and the "Server is running..." message never
prints.
I also tried the following as shown in the QtServiceBase documentation:
int main (int argc, char** argv)
{
XLMService service(argc, argv); // inherits QtService
service.setStartupType(QtServiceController::ManualStartup);
return service.exec();
}
This works fine under Linux. Under windows, it starts the server but
doesn't disconnect it from the starting process (i.e. command line).
What do I need to do to properly start a service, especially under windows?
Thanks,
Tom
--
[ signature omitted ]
Message 2 in thread
> int main (int argc, char** argv)
> {
> XLMService service(argc, argv); // inherits QtService
> service.setStartupType(QtServiceController::ManualStartup);
>
> return service.exec();
> }
>
> This works fine under Linux. Under windows, it starts the server but
> doesn't disconnect it from the starting process (i.e. command line).
>
> What do I need to do to properly start a service, especially under
> windows?
How is XLMService inheriting QtService?
I'm using something like:
class MyService : public QtService<QApplication>
ISTR that I initially missed the bit about the templated QtService
requiring an application type in the docs.
--
[ signature omitted ]
Message 3 in thread
Duane Hebert wrote:
>> int main (int argc, char** argv)
>> {
>> XLMService service(argc, argv); // inherits QtService
>> service.setStartupType(QtServiceController::ManualStartup);
>>
>> return service.exec();
>> }
>>
>> This works fine under Linux. Under windows, it starts the server but
>> doesn't disconnect it from the starting process (i.e. command line).
>>
>> What do I need to do to properly start a service, especially under
>> windows?
>
> How is XLMService inheriting QtService?
> I'm using something like:
>
> class MyService : public QtService<QApplication>
>
> ISTR that I initially missed the bit about the templated QtService
> requiring an application type in the docs.
>
>
I'm doing the same. It wouldn't compile otherwise.
--
[ signature omitted ]
Message 4 in thread
>> How is XLMService inheriting QtService?
>> I'm using something like:
>>
>> class MyService : public QtService<QApplication>
>>
>> ISTR that I initially missed the bit about the templated QtService
>> requiring an application type in the docs.
> I'm doing the same. It wouldn't compile otherwise.
Don't know then. Once I build my service, I manually
install it from the command line using -i arg. Then I can start it by
using -s from the command line or using the service manager
gui. I haven't tried your first example of installing/starting the
service from the code.
Do you have an error listed in Windows event logger?
--
[ signature omitted ]