Run as service



  • Hi there,
    I'm writing a simple "ping" app that sends a ping to out server periodically. The thing is my company wants it to start as a service, to be able to "see" a powered-on computer even if it has restarted and/or without anyone logged in.

    Is there a solution provided by Qt? I can't find something useful for me.

    Thank you for your help



  • I can't find something useful for me.

    Perhaps, because you lazy looking for?
    QtService: https://github.com/qtproject/qt-solutions


  • Qt Champions 2016

    hi
    alternatively u could just cheat and use a tool to run it as service.
    http://www.howtogeek.com/50786/using-srvstart-to-run-any-application-as-a-windows-service/



  • @kuzulis said:

    Perhaps, because you lazy looking for?

    I found this but while I'm struggling with an error on make g++: error: CreateProcess: No such file or directory, I still hoping there is something included in Qt. Maybe my error is related to the fact that I'm on 5.6 (and the project mentions 5.5), but that's another thread.

    @mrjj said:

    alternatively u could just cheat and use a tool to run it as service.

    I also thought about this at first (like the included sc, as command line), but as the app will run on around 30 computers and will be installed by users, I need a simple workflow. So either a simple command line tool that will be run on the first start by my app (after install) or the above solution provided by @kuzulis (or similar)


  • Qt Champions 2016

    @Max13 said:

    g++: error: CreateProcess:

    is that mingw compiler?

    Oh, i understand. To Make installer to setup the app as service is
    as much work as making native a service. :)


  • Moderators

    Why don't you just run ping from a cron job?


  • Qt Champions 2016

    @Max13
    What OS are we talking? I recently began (and implemented for Linux) such a thing (Qt 5.5 compatible). My idea is that at some point I wrap up the Windows code as well.



  • I recently wrote a windows service (file transfer from/to a server, connection checks,...) in plain C compiled with mingw but it a bit of pain (so much code to type...)

    @Max13 said:

    I also thought about this at first (like the included sc, as command line), but as the app will run on around 30 computers and will be installed by users, I need a simple workflow. So either a simple command line tool that will be run on the first start by my app (after install) or the above solution provided by @kuzulis (or similar)

    As far as i remember you need full Admin rights (on Win7 it was not enough to run the CMD as administrator when logged in as a normal user) to register/install a service. I was looking for installer kits that can do that but could not find any examples for this.



  • @mrjj said:

    is that mingw compiler?

    Oh, i understand. To Make installer to setup the app as service is
    as much work as making native a service. :)

    It's mingw, installed with Qt. It's easier for the user (therefor for me, if I don't have to help them) if I make an installer that installs (as a service) and start. Then the user has NOTHING to do except double clicking the installer.

    @Wieland said:

    Why don't you just run ping from a cron job?

    It's not just really a ping. Currently it's calling an API to say "I'm still awake", the plan is to "ping" with a some logs.

    @kshegunov said:

    What OS are we talking?

    Windows XP and Windows 7. QtSolutions was a great idea. If you have implemented yours another, share.

    @the_ said:

    I recently wrote a windows service (file transfer from/to a server, connection checks,...) in plain C compiled with mingw but it a bit of pain (so much code to type...)

    I don't doubt it. I want to avoid native APIs as much as possible. To keep the cross-platform ability

    Finally, I managed to compile QtSolutions/QtService using just the cmd command line by Qt. All the env variables was there. It's a little bit complicated to understand the first time how to implement it, as there is only examples, but I simply has to wrap my code in an overridden QtService::start() and that's it.

    My project is Open Source: https://github.com/Max13/Pulse-Qt

    Thank you for your help


  • Qt Champions 2016

    @Max13 said:

    Windows XP and Windows 7. QtSolutions was a great idea. If you have implemented yours another, share.

    Currently only for Linux. I have some old source for windows that I'm going to refactor, but I've been busy ... you know how it is.


  • Qt Champions 2016

    @Max13
    Hello,
    Just letting you know that as of today I have an implementation for Windows as well. Still tweaking it a bit (the installation/ deinstallation should update the PATH), but it appears to be fully functional otherwise. Let me know if you're interested.

    I just merged the win32 branch, so you can get the library here.

    Kind regards.



  • @kshegunov said:

    Just letting you know that as of today I have an implementation for Windows as well.

    I'm playing around with QtService, but I'll look at yours as soon as I can ;)


  • Qt Champions 2016

    @Max13
    Do let me know whether it's convenient to use, and of course suggestions are welcome. (bug reports please post on the issue tracker).


Log in to reply
 

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