Qt daemon


  • Qt Champions 2016

    Hello,
    It ain't exactly flashy, but here's an alternative to QtService if anyone would like to make use of it (Qt 5.5 compatible).

    (Copy from the readme)

    There are two exposed classes QDaemonApplication and QDaemonLog.

    QDaemonApplication is derived from QCoreApplication and provides the basic infrastructure for the daemon.
    QDaemonApplication exposes 5 signals:

    • daemonized() - emitted when the application is started as a daemon/service by the OS and notifies the user that initializations (like connecting signals/slots) can be done.
    • started() - emitted when the application is run as a controlling terminal, notifying the user that the daemon/servicehas started.
    • stopped() - emitted when the application is run as a controlling terminal, notifying the user that the daemon/service has stopped.
    • installed() - emitted when the application is run as a controlling terminal, notifying the user that the daemon/service has been installed.
    • uninstalled() - emitted when the application is run as a controlling terminal, notifying the user that the daemon/service been uninstalled.

    QDaemonLog is the logging component for the daemon. It's set up to output on stdout when the application is run as controlling terminal, and to a file (named after the application with .log extension) when the application is ran as daemon/service.
    The logging component can be used by the user through QDaemonLog & qDaemonLog(); coupled with QDaemonLog & << (const QString &) or void qDaemonLog(const QString &, QDaemonLog::EntrySeverity). Currently the format of the output messages is fixed.

    Enjoy!

    PS.
    If you decide to use and find any bugs, please report them in the repo.



  • @kshegunov

    This sounds good. Thanks for sharing this code


  • Qt Champions 2016

    It seems I'm replying to myself, but I just wanted to let you know that after some (internal) refactoring. The library now supports command line arguments to be passed to the daemon/service as well (specified on --install/--fake). However the library now requires Qt 5.6.



  • Great. I went looking for something like this. Thanks for sharing.
    A Question. Is this library stable? If not, when stable version will be released?


  • Qt Champions 2016

    @Hamed.Masafi

    Is this library stable? If not, when stable version will be released?

    It depends on what you mean by stable.

    If you mean the API, then probably you can safely say it's stable. I don't plan any (big) changes in the API. As for the binaries, it is binary compatible.

    If you mean performance, I suppose it's stable enough. I have a project deployed with it and hadn't had any problems yet. Also it was reported by @madababi that the library works fine on Raspberry PI (with proper cross-compiling of course). There's always the possibility of minor bugs, but it should be fully functional.

    Note There's currently no support for OSX.

    Kind regards.



  • This post is deleted!

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.