feat: with grpc running on 7900
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
Kasper Juul Hermansen 2024-02-11 13:36:08 +01:00
parent ae1f91b2b1
commit be8d605b6a
Signed by: kjuulh
GPG Key ID: 57B6E1465221F912

View File

@ -19,6 +19,8 @@ enum Commands {
Serve {
#[arg(env = "SERVICE_HOST", long, default_value = "127.0.0.1:3000")]
host: SocketAddr,
#[arg(env = "SERVICE_GRPC_HOST", long, default_value = "127.0.0.1:7900")]
grpc_host: SocketAddr,
},
}
@ -46,13 +48,13 @@ impl greeter_server::Greeter for FluxReleaserGrpc {
}
}
async fn tonic_serve() -> anyhow::Result<()> {
tracing::info!("grpc listening on: :7900");
async fn tonic_serve(host: SocketAddr) -> anyhow::Result<()> {
tracing::info!("grpc listening on: {}", host);
Server::builder()
.add_service(greeter_server::GreeterServer::new(
FluxReleaserGrpc::default(),
))
.serve("[::1]:7900".parse()?)
.serve(host)
.await?;
Ok(())
@ -65,7 +67,7 @@ async fn main() -> anyhow::Result<()> {
let cli = Command::parse();
if let Some(Commands::Serve { host }) = cli.command {
if let Some(Commands::Serve { host, grpc_host }) = cli.command {
tracing::info!("Starting service");
let app = Router::new().route("/", get(root));
@ -77,7 +79,7 @@ async fn main() -> anyhow::Result<()> {
res = axum_serve(listener, app) => {
res?;
},
res = tonic_serve() => {
res = tonic_serve(grpc_host) => {
res?;
},
};