Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Error in Daemon/Service app while compiling
QtWS25 Last Chance

Error in Daemon/Service app while compiling

Scheduled Pinned Locked Moved Unsolved General and Desktop
daemonservicewindowslinuxassert
16 Posts 3 Posters 5.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A ainu

    @SGaist Hi, thank you for you reply. Actually the reason was that i couldn't completely understand how to use to install and start my particular daemon. I mean i tried to pass path to install method but it didn't work so i decided to try how it was implemented in another example (A simple HTTP Server )

    A Offline
    A Offline
    ainu
    wrote on last edited by ainu
    #4

    The thing is that when i am calling "install" function from QtServiceController Class inside if-statement it returns true but when a few lines later i am checking if the service was installed with isInstalled it returns false. Here the extraction from my test code:
    in header:

    QtServiceController *ptrCtl;
    

    in src file:

            ptrCtl = new QtServiceController( ptrFi->baseName() );
            if ( ptrCtl->install( getProgName() ) )
                ptrCtl->start();
            qDebug() << ptrCtl->serviceName()
                     << ( ( ptrCtl->isRunning() )
                          ? " is" : " is not " ) <<  "running";
            if ( ptrCtl->isInstalled() ) {
                qDebug() << ptrCtl->serviceName()
                         << ( ( ptrCtl->start() )
                              ? " was" : " was not " ) <<  "start";
            } else
                qDebug() << ptrCtl->serviceName() << " was not installed";
    

    ptrCtl->serviceName() has value "client"
    getProgName() contain full path to "client" executable file. ( with file itself )

    output:
    "client" is not running
    "client" was not installed

    will be really grateful for any help or advice

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #5

      On what OS are you running that ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        On what OS are you running that ?

        A Offline
        A Offline
        ainu
        wrote on last edited by
        #6

        @SGaist I ran it on Linux ( Ubuntu 16.04 LTS ) but intend to run on Windows either.

        A 1 Reply Last reply
        0
        • A ainu

          @SGaist I ran it on Linux ( Ubuntu 16.04 LTS ) but intend to run on Windows either.

          A Offline
          A Offline
          ainu
          wrote on last edited by
          #7

          Actually the situation changed a bit and i managed to run without the error i had in the beginning. In the program there are some possible ways to follow, depending on the set flag ( i set flag: Projects->Run->Command line arguments ). everything seems to work fine with all the flags except the ones that make program to be installed. In this case it falls into infinite-loop. It looks as if it continuously trying to install itself without success ( i mean it was installed on the second iteration, not the first. Which is also weird ). The part of the code i am talking about

          if ( !( ptrCtl->isInstalled() ) ) {
                          qDebug() << ptrCtl->serviceName() << " was not installed ==================== >>>";
                          qDebug() << ptrCtl->serviceName()
                                   << ( ( ptrCtl->install( getProgName() ) )
                                        ? " was successfully" : " was not " ) <<  "installed";
          
                          qDebug() << getProgName()
                                   << ( ( ptrCtl->start() )
                                        ? " was" : " was not " ) <<  "started";
          }
          

          The program goes into the first if-statement every time but only on the second iteration it installs and all the other times do not do this and certainly never reaches the line with call to "start"-method ( at least not calling to "start"-method ). After the second iteration it looks as if it creates new process branch every time the program stream reaches this line ( with "install"-method ) and started to walk all its way through the main function to "install"-method again.
          I added the line with the phrase "was not installed" just to make the output more readable. The output looks like this

          "d_server" was not installed ==================== >>>
          "d_server" was successfully installed
          "d_server" was not installed ==================== >>>
          "d_server" was not installed ==================== >>>
          "d_server" was not installed ==================== >>>

          There is also another strange thing happens. The first iteration of this infinite-loop contain only 2 parameters for main function ( I mean argc in "int main( int argc, char **argv )" equals 2 ) but all the following - 4. Interesting why is it so?!
          My question here is how to make the program to install itself from the beginning and go to the line with "start-method"? ( well do it without "infinite"-loop ).

          Thank you in advance for any help.

          A 1 Reply Last reply
          0
          • A ainu

            Actually the situation changed a bit and i managed to run without the error i had in the beginning. In the program there are some possible ways to follow, depending on the set flag ( i set flag: Projects->Run->Command line arguments ). everything seems to work fine with all the flags except the ones that make program to be installed. In this case it falls into infinite-loop. It looks as if it continuously trying to install itself without success ( i mean it was installed on the second iteration, not the first. Which is also weird ). The part of the code i am talking about

            if ( !( ptrCtl->isInstalled() ) ) {
                            qDebug() << ptrCtl->serviceName() << " was not installed ==================== >>>";
                            qDebug() << ptrCtl->serviceName()
                                     << ( ( ptrCtl->install( getProgName() ) )
                                          ? " was successfully" : " was not " ) <<  "installed";
            
                            qDebug() << getProgName()
                                     << ( ( ptrCtl->start() )
                                          ? " was" : " was not " ) <<  "started";
            }
            

            The program goes into the first if-statement every time but only on the second iteration it installs and all the other times do not do this and certainly never reaches the line with call to "start"-method ( at least not calling to "start"-method ). After the second iteration it looks as if it creates new process branch every time the program stream reaches this line ( with "install"-method ) and started to walk all its way through the main function to "install"-method again.
            I added the line with the phrase "was not installed" just to make the output more readable. The output looks like this

            "d_server" was not installed ==================== >>>
            "d_server" was successfully installed
            "d_server" was not installed ==================== >>>
            "d_server" was not installed ==================== >>>
            "d_server" was not installed ==================== >>>

            There is also another strange thing happens. The first iteration of this infinite-loop contain only 2 parameters for main function ( I mean argc in "int main( int argc, char **argv )" equals 2 ) but all the following - 4. Interesting why is it so?!
            My question here is how to make the program to install itself from the beginning and go to the line with "start-method"? ( well do it without "infinite"-loop ).

            Thank you in advance for any help.

            A Offline
            A Offline
            ainu
            wrote on last edited by
            #8

            maybe important to mention that i did saw the same question on Stack Overflaw and try to use it in my project

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #9

              Are you trying to install it with root privileges ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                Are you trying to install it with root privileges ?

                A Offline
                A Offline
                ainu
                wrote on last edited by ainu
                #10

                @SGaist thank you. it might be the point of course but it also rises a few questions:

                • why my app was installed once ( second iteration ) at least it was shown that it was installed.
                • how to give to the app root privileges? ( i mean of course i tried ( from console ) to use make and then sudo ( super user privileges ) on compiled file but it changed nothing so i might did something wrong. If there are other options how to give root ( or super user privileges ) privileges write me please ).
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11
                  1. You might have been working as root at some point
                  2. What I meant was, as you did, use sudo for the installation.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  A 1 Reply Last reply
                  0
                  • SGaistS SGaist
                    1. You might have been working as root at some point
                    2. What I meant was, as you did, use sudo for the installation.
                    A Offline
                    A Offline
                    ainu
                    wrote on last edited by
                    #12

                    @SGaist I see, it seems there is some other issue then. Regretfully of course, as i still have no clue of what to do.
                    Anyway thank you for your help.

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by kshegunov
                      #13

                      On a side note, you might also be interested by @kshegunov QtDaemon module.

                      [Fixed hyperlink ~kshegunov]

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      A 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        On a side note, you might also be interested by @kshegunov QtDaemon module.

                        [Fixed hyperlink ~kshegunov]

                        A Offline
                        A Offline
                        ainu
                        wrote on last edited by
                        #14

                        @SGaist thank you for the link

                        kshegunovK 1 Reply Last reply
                        0
                        • A ainu

                          @SGaist thank you for the link

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on last edited by
                          #15

                          I've been silent, because it's been a long time since I had used the QtService and I really don't remember how it's supposed to be set up. As for linux, depending on how the daemon's set up you may need to call insserv to register the init script.

                          Read and abide by the Qt Code of Conduct

                          A 1 Reply Last reply
                          1
                          • kshegunovK kshegunov

                            I've been silent, because it's been a long time since I had used the QtService and I really don't remember how it's supposed to be set up. As for linux, depending on how the daemon's set up you may need to call insserv to register the init script.

                            A Offline
                            A Offline
                            ainu
                            wrote on last edited by
                            #16

                            @kshegunov Thank you for your suggestion I will try to follow it.

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved