Re: [Interest] debug QtService

2012-11-09 Thread alexander golks
I want to make web service method, requesing which I would tell service 
to stop.

if RequestMapper is derived from QtService you should be able to call the 
QtServiceBase::stop() method instead of QCoreApplication::exit().

we call it via a wrapping SLOT triggered by a timer like:

  /*SLOT*/ void Service::stopService()
  {
stop();
  }

  void Service::processCommand(int code)
  {
if(code==1)
  QTimer::singleShot(0,this,SLOT(stopService()));
  }

thus, we can use the windows service mechanisms to send the command code 1
to the service and now the service can use as much time as it needs to shut
down, whereas calling stop would kill the service within 30 seconds.

now, if using this mechanism you should  be able to do:

  void RequestMapper::service(HttpRequest request, HttpResponse response) {
 QByteArray path=request.getPath();
 #ifdef _DEBUG
 if (path.startsWith(/stop)) {
 QTimer::singleShot(0,this,SLOT(stopService()));

second:
why debugging with -e?
you can also install, start via system services and attach the debugger to the
service.

alex
-- 


signature.asc
Description: PGP signature
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


Re: [Interest] debug QtService

2012-11-08 Thread BRM
 From: Sergey sh0...@gmail.com

Hello, all

I'm developing windows web service using QtService.
To debug it, I launch program in VS2005 debugger with -e argument.
It starts in console mode and handles requests.
How can I emulate stopping the service, so that all code, which is 
working usually when windows stops the service?

I want to make web service method, requesing which I would tell service 
to stop.

void RequestMapper::service(HttpRequest request, HttpResponse response) {
     QByteArray path=request.getPath();

#ifdef _DEBUG
     if (path.startsWith(/stop)) {
         //QCoreApplication::instance()-exit(); // this leads to error 
in  HttpConnectionHandler::run() in line: 
moveToThread(QCoreApplication::instance()-thread());

How to emulate stopping the service here, so that program, running with 
-e argument would stop normally, as it stops when running as windows 
service?

     }
#endif
}


You'll have to look up the Windows headers you'll need, but you want to use the 
Debug() Win32 function.
It triggers the Debugger to run.
The best way to use it is to call it early in the life of the service so you 
can connect the service with VS in a controlled manner, and then set the break 
point where you want it and continue to run it.


Ben

___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest


[Interest] debug QtService

2012-11-07 Thread Sergey
Hello, all

I'm developing windows web service using QtService.
To debug it, I launch program in VS2005 debugger with -e argument.
It starts in console mode and handles requests.
How can I emulate stopping the service, so that all code, which is 
working usually when windows stops the service?

I want to make web service method, requesing which I would tell service 
to stop.

void RequestMapper::service(HttpRequest request, HttpResponse response) {
 QByteArray path=request.getPath();

#ifdef _DEBUG
 if (path.startsWith(/stop)) {
 //QCoreApplication::instance()-exit(); // this leads to error 
in  HttpConnectionHandler::run() in line: 
moveToThread(QCoreApplication::instance()-thread());

How to emulate stopping the service here, so that program, running with 
-e argument would stop normally, as it stops when running as windows 
service?

 }
#endif
}


Thanks!
___
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest