1 #ifndef SERVICEMANAGER_MODULE_H
2 #define SERVICEMANAGER_MODULE_H
5 #include <boost/scoped_ptr.hpp>
6 #include <boost/circular_buffer.hpp>
9 #include <qi/messaging/autoservice.hpp>
11 #include "processmanager.h"
15 #include <qi/path.hpp>
16 #include <qi/clock.hpp>
17 #include <qi/macro.hpp>
18 #include <qi/session.hpp>
19 #include <qi/trackable.hpp>
21 #include <qipackage/package_info.hpp>
53 ServiceManager(qi::SessionPtr session,
const std::vector<std::string>& coreServices);
69 qi::Future<void>
start(
const std::string &name);
82 qi::Future<void>
stop(
const std::string &name);
104 qi::Future<void>
restart(
const std::string &name);
118 std::vector<qi::ServiceProcessInfo>
services();
141 QI_API_DEPRECATED_MSG(Use
'start' instead)
156 QI_API_DEPRECATED_MSG(Use
'stop' instead)
157 qi::Future<bool>
stopService(
const std::string &name);
167 QI_API_DEPRECATED_MSG(Use
'restart' instead)
196 qi::SessionPtr _session;
197 std::vector<std::string> _coreServices;
200 void restartAutoService();
202 void advertiseServiceAdded(
const qi::PackageInfo2& pkgInfo);
203 void advertiseServiceRemoved(
const qi::PackageInfo2& pkgInfo);
205 void startAutoRunServices(qi::PackageInfo2 pkgInfo);
206 void stopRemovedService(qi::PackageInfo2 pkgInfo);
208 qi::AnyObject _packageManager;
211 ProcessManager *_interface;
214 ProcessManager *loadPlugin(
const std::string &pluginName);
217 std::string replaceVar(
const std::string &line);
218 void checkName(
const std::string &name)
const;
219 const qi::PackageService getService(
const qi::PackageInfo2 &pkgInfo,
const std::string &serviceName)
const;
220 const qi::PackageInfo2 getPackageFromServiceName(
const std::string &serviceName)
const;
221 std::pair<qi::PackageInfo2, qi::PackageService> splitServiceName(
const std::string &name)
const;
222 std::map<std::string, boost::circular_buffer<qi::SteadyClock::time_point>> _timeTable;
223 bool processRestartFrequency(
const std::string &name);
227 #endif // SERVICEMANAGER_MODULE_H
qi::Future< void > restart(const std::string &name)
Restart a service with his name.
ServiceManager(qi::SessionPtr session)
Launch service manager.
qi::Signal< std::string > serviceAdded
Signal sent when a new service is handled by ServiceManager.
qi::Signal< std::string > serviceRemoved
Signal sent when a service is removed from serviceManager.
qi::Future< size_t > serviceMemoryUsage(const std::string &name)
Get the memory used by service named name.
qi::Future< bool > isServiceRunning(const std::string &name) const
Check that the service named name is started or not.
qi::ServiceProcessInfo service(const std::string &name)
Get information about one service named name.
qi::Future< bool > startService(const std::string &name)
Start a service with his name.
qi::Future< bool > restartService(const std::string &name)
Restart a service with his name.
qi::Future< void > stop(const std::string &name)
Stop service with his name.
~ServiceManager()
Unload service manager.
qi::Future< bool > stopService(const std::string &name)
Stop service with his name.
std::vector< qi::ServiceProcessInfo > services()
Get the list of all services.
qi::Future< void > stopAllServices()
Stop all services.
qi::Signal< std::string, qi::ServiceEventReason > serviceStopped
Sent when a service is stopped.
qi::Future< void > start(const std::string &name)
Start a service with his name.
qi::Signal< std::string, qi::ServiceEventReason > serviceStarted
Sent when a service is started.