Comments (8)
What do you mean?
from grpc-lua.
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.
from grpc-lua.
function M.SayHello(request, replier)
os.exit()
end -- SayHello()
Then the service will shutdown itself if the client requests rpc "SayHello".
from grpc-lua.
Yes, os.exit() works, but I exected another solution. :-(
I need the service gracefully finishes all started negotiations and passes control back to the main() routine next to the "svr:run()".
from grpc-lua.
Sorry, no such function. Maybe you can try to export shutdown() from C++ to lua.
from grpc-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
...
void BindServer(const LuaRef& mod)
{
using namespace grpc_cb_core;
LuaBinding(mod).beginClass("Server")
.addConstructor(LUA_ARGS())
// Returns bound port number on success, 0 on failure.
.addFunction("add_listening_port",
static_cast<int(Server::*)(const std::string&)>(
&Server::AddListeningPort))
.addFunction("register_service", &RegisterService)
.addFunction("run", &Server::Run)
.addFunction("shutdown", &Server::Shutdown)
.endClass(); // Server
} // BindServer()
...
grpc_lua\server\Server.lua
...
function Server:shutdown()
self.c_svr:shutdown()
end
...
grpc_cb_core\include\grpc_cb_core\server\server.h
...
/// Shutdown the server, blocking until all rpc processing finishes.
/// Forcefully terminate pending calls after \a deadline expires.
///
/// \param deadline How long to wait until pending rpcs are forcefully
/// terminated.
template
void Shutdown(const T& deadline) {
ShutdownInternal(TimePoint(deadline).raw_time());
}
/// Shutdown the server, waiting for all rpc processing to finish.
void Shutdown() { ShutdownInternal(gpr_inf_future(GPR_CLOCK_MONOTONIC)); }
/// Block waiting for all work to complete.
///
/// \warning The server must be either shutting down or some other thread must
/// call \a Shutdown for this function to ever return.
void Run();
...
How can I describe Shutdown(deadline) like this:
.addFunction("add_listening_port",
static_cast<int(Server::*)(const std::string&)>(
&Server::AddListeningPort))
?
Thank you in advance!
from grpc-lua.
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
from grpc-lua.
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
#include <grpc/support/time.h> // for gpr_timespec
#include <grpc/impl/codegen/gpr_types.h> //for gpr_clock_type
...
namespace {
...
void ShutdownDeadline(grpc_cb_core::Server* pServer, const LuaRef& timeoutSec)
{
assert(pServer);
int32_t mSec = timeoutSec.toValue<int32_t>()*1000;
gpr_timespec t = gpr_time_from_millis(gpr_time_to_millis(gpr_now(GPR_CLOCK_MONOTONIC))+mSec,GPR_CLOCK_MONOTONIC);
pServer->Shutdown(t);
} //ShutdownDeadline()
} // namespace
namespace server {
void BindServer(const LuaRef& mod)
{
...
.addFunction("shutdown_deadline", &ShutdownDeadline)
...
} // BindServer()
} // namespace server
from grpc-lua.
Related Issues (14)
- can not build success HOT 37
- bintray is closed. HOT 5
- Cannot access jinq0123 repository HOT 4
- Cannot build manually on MacOS HOT 1
- Cannot build successfully in WSL2 - is this repo still maintained? HOT 1
- Integration with other lua environments HOT 1
- Lib stuck on require HOT 3
- macos,ubuntu,centos都不能编译成功 HOT 6
- Lua 5.1 / LuaJIT support HOT 6
- options.static_rt doesn't exist HOT 12
- It's wrong when execute conan_install.sh in example HOT 24
- centos 7.8 compile fail. HOT 3
- Luarocks rock HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grpc-lua.