Error in Daemon/Service app while compiling
-
wrote on 30 Oct 2017, 06:19 last edited by
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.
-
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.
wrote on 30 Oct 2017, 08:19 last edited bymaybe important to mention that i did saw the same question on Stack Overflaw and try to use it in my project
-
Are you trying to install it with root privileges ?
-
wrote on 31 Oct 2017, 06:14 last edited by ainu
@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 ).
-
- You might have been working as root at some point
- What I meant was, as you did, use sudo for the installation.
-
- You might have been working as root at some point
- What I meant was, as you did, use sudo for the installation.
-
On a side note, you might also be interested by @kshegunov QtDaemon module.
[Fixed hyperlink ~kshegunov]
-
On a side note, you might also be interested by @kshegunov QtDaemon module.
[Fixed hyperlink ~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 callinsserv
to register the init script. -
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 callinsserv
to register the init script.wrote on 7 Nov 2017, 05:00 last edited by@kshegunov Thank you for your suggestion I will try to follow it.
15/16