[Interest] debug QtService

alexander golks alex at golks.de
Fri Nov 9 10:51:01 CET 2012


>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
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20121109/f4f447ea/attachment.sig>


More information about the Interest mailing list