/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2019-present Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
reply.enclose(result);
return reply;
- };
+ };
#ifdef TIZEN
this->server = std::make_unique<ondemand::Server>(path, dispatcher);
#endif
}
- inline void start()
+ inline void start(int timeout, std::function<bool()> stopper)
{
- this->server->run();
+ this->server->run(timeout, stopper);
}
inline void stop()
Gateway::~Gateway() = default;
-void Gateway::start()
+void Gateway::start(int timeout, std::function<bool()> stopper)
{
- this->pImpl->start();
+ this->pImpl->start(timeout, stopper);
}
void Gateway::stop(void)
/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ * Copyright (c) 2019-present Samsung Electronics Co., Ltd All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <vist/klass/functor.hpp>
#include <vist/macro.hpp>
+#include <functional>
#include <memory>
#include <string>
Gateway(Gateway&&) = default;
Gateway& operator=(Gateway&&) = default;
- void start();
+ void start(int timeout = -1, std::function<bool()> stopper = nullptr);
void stop();
template<typename O, typename F>
{
INFO(VIST) << "Vistd daemon starts.";
- policy::PolicyManager::Instance();
-
rmi::Gateway gateway(SOCK_ADDR);
EXPOSE(gateway, *this, &Vistd::query);
- gateway.start();
+ auto& pm = policy::PolicyManager::Instance();
+
+ /// Shutdown service if timeout is occured without activated admin
+ gateway.start(3000, [&pm]() -> bool { return !pm.isActivated(); });
INFO(VIST) << "Vistd daemon stopped.";
}