
This is extension libraries for control your daemons and rervices. This library will save you the time you spend building and deploying server daemons or services.
If you want to get more inforamtion about library see our documentation
Becouse This library offers easy interface to control your demons likewise the magic of Harry Potter controls dementors
Main features
- Support linux systemd daemons.
- Deploy and install your services on the host.
- Auto create a Service from your server or yor daemon utility.
- Auto create a Controller of your Service.
Deffault sopprted commands
- install - deploys your daemon into your host system. This command deploy service for root user if you want to deploy service for specify user just use -install <UserName> command (root right required)
- unistall - removes old deployed daemon. (root right required)
- start - starts your service
- stop - stops ypur service
- pause - sends pause command to your daemon
- upause (resume) - sends resume coomand to your daemon
Include
For cmake projects
- cd yourRepo
- git submodule add https://github.com/QuasarApp/Patronum.git # add the repository of Patronum into your repo like submodule
- git submodule update –init –recursive
- Include in your CMakeLists.txt file the main CMakeLists.txt file of Patronum library
add_subdirectory(Patronum)
- Rebuild yuor project
Usage
Service
{
public:
MyserviceApp(int argc, char **argv):
Patronum::Service<QCoreApplication>(argc, argv) {
}
return true;
}
}
if (data.
cmd() ==
"ping") {
}
else if (data.
cmd() ==
"state") {
}
return true;
}
QSet<Patronum::Feature> data;
return data;
}
};
int main(int argc, char **argv) {
QCoreApplication::setApplicationName("MyServiceName");
QCoreApplication::setOrganizationName("MyCompany");
MyserviceApp app;
return app.exec();
}
The Feature class it is atomic type for describe service command.
QString cmd() const
cmd This method return command of the feature.
virtual bool handleReceive(const Feature &data)=0
handleReceive This method invoked when service receive a request from terminal. Override this method ...
bool sendResuylt(const QVariantMap &result)
sendResuylt - Call this method for send responce from service to tour controller.
QSet< Feature > supportedFeatures() override
supportedFeatures
void onStop() override
onStop Called when get stop command from terminal. The default implementation of this method invoke a...
bool onStart() override=0
onStart Called when get start command from terminal. Override this method work correctly work of serv...
The Service class it is class for create a services from daemons.
The Patronum namespace - It is main name space of Patronum Library. The Patronum library support the ...
Controller
Dy default the service can works as acontroller, But some times we need to create a simple controller app for exists our service. For example universal controller for all services of your comapny. The all services that based on Patronum library compatible with each other due to the fact that the command configuration is on the side of the service itself, and not the controller.
{
public:
MyControllerApp():
}
};
int main(int argc, char **argv) {
QCoreApplication::setApplicationName("MyServiceName");
QCoreApplication::setOrganizationName("MyCompany");
QCoreApplcication app
MyControllerApp controller;
controller.send(argc, argv);
return app.exec();
}
The Controller class provide control functionality for your service.
Wrapers of the service distributions
The Service class use own executable like a main path to service executable. If your application has custom dependencies and do not work without costom envirement then you need to add P_RUN_FILE or CQT_RUN_FILE variavle with full path into the your wraper or launcher file.
Order of the search executable file of the service
- P_RUN_FILE variable
- CQT_RUN_FILE variable
- Absalute path to executable.