-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server/service shutdown on remote client command #11
Comments
What do you mean? |
Service in your "Greeter" example will work until i kill this process with operating system command. I want to find the way to service shutdown by himself according to remote client command. |
function M.SayHello(request, replier)
os.exit()
end -- SayHello() Then the service will shutdown itself if the client requests rpc "SayHello". |
Yes, os.exit() works, but I exected another solution. :-( |
Sorry, no such function. Maybe you can try to export shutdown() from C++ to lua. |
I've bind Shutdown function from <grpc_cb_core/server/server.h>. When I call it the service stop serving but dont return control. According to function desctiption there is an optional parameter Deadline wich can help us. Lua and C aren't my native languages, so I need your help in binding with parameters. grpc-lua\src\cpp\server\BindServer.cpp grpc_lua\server\Server.lua grpc_cb_core\include\grpc_cb_core\server\server.h /// Shutdown the server, waiting for all rpc processing to finish. /// Block waiting for all work to complete. How can I describe Shutdown(deadline) like this: Thank you in advance! |
I hope this can compile: #include <chrono>
...
namespace {
...
void ShutdownDeadline(grpc_cb_core::Server* pServer, const LuaRef& timeoutSec)
{
assert(pServer);
std::chrono::system_clock::time_point t = std::chrono::system_clock::now();
double dSec = timeoutSec.toValue<double>();
t += std::chrono::seconds(dSec);
pServer->Shutdown(t);
}
} // namespace
namespace server {
void BindServer(const LuaRef& mod)
{
...
.addFunction("shutdown_deadline", &ShutdownDeadline)
...
} // BindServer()
} // namespace server |
FAIL :-( Shutdown with deadline gives the same result. Service stops without termination and loads processor up to 30%. I'm stumped, so I just live compilable version here ... grpc-lua\src\cpp\server\BindServer.cpp
|
I have no idea how to implement the Subj. Is there any way to call service own methods over RPC?
greeter_service.lua
--- Hello world greeter example server side service.
-- greeter_service.lua
local M = {}
local grpc = require("grpc_lua.grpc_lua")
grpc.import_proto_file("helloworld.proto")
--- Public functions.
-- @section public
function M.SayHello(request, replier)
assert("table" == type(request))
assert("table" == type(replier))
print("Got hello from "..request.name)
-- replier:reply() can be called later after return.
local response = { message = "Hello "..request.name }
replier:reply(response);
end -- SayHello()
function M.shutdown()
--self:shutdown() !!! Something like this
end
return M
The text was updated successfully, but these errors were encountered: