设置香港服务

时间:2019-07-03 04:46:44

标签: python api-gateway kong grpc-python

我对kong文件进行了以下更改:

proxy_listen = 0.0.0.0:8000 http2 proxy_protocol, 0.0.0.0:8443 http2 proxy_protocol ssl
admin_listen = 127.0.0.1:8001 http2 proxy_protocol, 127.0.0.1:8444 http2 proxy_protocol ssl

我使用了Postgres数据库,我的数据库配置为:

database = postgres             
pg_host = 127.0.0.1
pg_port = 5432
pg_user = kong
pg_password = kong
pg_database = kong

我的python中有grpc服务器:

def serve():
grpc_server = grpc.server(futures.ThreadPoolExecutor(max_workers=10))
calculator_grpc_pb2_grpc.add_apiServicer_to_server(CalculatorServicer(), grpc_server)
grpc_server.add_insecure_port('[::]:9999')
grpc_server.start()
while True:
    time.sleep(860000)

我的客户是:

channel = grpc.insecure_channel('localhost:8000')
client = calculator_grpc_pb2_grpc.apiStub(channel)

启动kong之后,我尝试添加以下服务:

curl -i -X POST \
--url http://localhost:8001/services/ \
--data 'name=test' \
--data 'url=http://localhost:9999'

它输出一些随机字符:

���%

我检查了我的服务表是否为空。

select * from services id | created_at | updated_at | name | retries | protocol | host | port | path | connect_timeout | write_timeout | read_timeout | tags ----+------------+------------+------+---------+----------+------+------+------+-----------------+---------------+--------------+------ (0 rows)

0 个答案:

没有答案