Skip to content

Commit

Permalink
fix: template for nameko
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryanthelol committed Nov 27, 2023
1 parent 4ae5d09 commit 31a55f8
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 40 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pychassiscli"
version = "0.3.4"
version = "0.3.5"
description = "A lightweight Python distributed microservice command line tool"
authors = [
{ name = "BryantHe", email = "bryantsisu@qq.com" },
Expand Down
7 changes: 7 additions & 0 deletions src/pychassiscli/templates/nameko/.dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
.venv
venv/
local*
*.env
*.venv
env/
ENV/
env.bak/
venv.bak/
9 changes: 6 additions & 3 deletions src/pychassiscli/templates/nameko/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ FROM python:3.11

RUN python3 -m pip uninstall -y pychassislib
# 拷贝依赖
COPY requirements.txt .
COPY . /app
# 设置工作路径
WORKDIR /app
# 安装依赖
RUN python3 -m pip install -i https://mirrors.cloud.tencent.com/pypi/simple --trusted-host=mirrors.cloud.tencent.com pdm>=2.10.1
# RUN python3 -m pip install -i https://mirrors.cloud.tencent.com/pypi/simple --trusted-host=mirrors.cloud.tencent.com -r requirements.txt
RUN python3 -m pdm install
RUN python3 -m pdm install
# 启动时运行命令
CMD ["sh", "docker-deploy.sh", "./body_record/config.yml", "body_record.body_record"]
16 changes: 8 additions & 8 deletions src/pychassiscli/templates/nameko/all_demo/all_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class HttpDemoService:

tracer = Tracer()
sentry = init_sentry()
statsd = init_statsd(config['STATSD_PREFIX'], config['STATSD_HOST'])
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

@http("GET", "/broken")
@statsd.timer('broken')
Expand Down Expand Up @@ -44,7 +44,7 @@ class RpcResponderDemoService:

tracer = Tracer()
sentry = init_sentry()
statsd = init_statsd('prod')
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

@rpc
@statsd.timer('hello')
Expand All @@ -59,7 +59,7 @@ class RpcCallerDemoService:
remote = ServiceRpc("rpc_responder_demo_service")

sentry = init_sentry()
statsd = init_statsd('prod')
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

@rpc
@statsd.timer('remote_hello')
Expand All @@ -74,7 +74,7 @@ class EventPublisherService:

tracer = Tracer()
sentry = init_sentry()
statsd = init_statsd('prod')
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

dispatch = EventDispatcher()

Expand All @@ -90,7 +90,7 @@ class AnEventListenerService:

tracer = Tracer()
sentry = init_sentry()
statsd = init_statsd('prod')
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

@event_handler("publisher_service", "an_event")
@statsd.timer('consume_an_event')
Expand All @@ -104,7 +104,7 @@ class AnotherEventListenerService:

tracer = Tracer()
sentry = init_sentry()
statsd = init_statsd('prod')
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

@event_handler("publisher_service", "another_event")
@statsd.timer('consume_another_event')
Expand All @@ -118,7 +118,7 @@ class ListenBothEventsService:

tracer = Tracer()
sentry = init_sentry()
statsd = init_statsd('prod')
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

@event_handler("publisher_service", "an_event")
@statsd.timer('consume_an_event')
Expand All @@ -137,7 +137,7 @@ class Timer:

tracer = Tracer()
sentry = init_sentry()
statsd = init_statsd('prod')
statsd = init_statsd(config.get('STATSD_PREFIX'), config.get('STATSD_HOST'))

@timer(interval=1)
@statsd.timer('ping')
Expand Down
8 changes: 8 additions & 0 deletions src/pychassiscli/templates/nameko/docker-compose-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"

services:
nameko-service:
image: gitea.bearcatlog.com/bryant/nameko-body-record/nameko-service:latest
build:
context: .
dockerfile: ./Dockerfile
24 changes: 24 additions & 0 deletions src/pychassiscli/templates/nameko/docker-compose-run.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: "3.8"

services:
nameko-service:
image: gitea.bearcatlog.com/bryant/nameko-body-record/nameko-service:latest
env_file:
- .nameko.env
deploy:
mode: replicated
replicas: 6
update_config:
parallelism: 3
failure_action: rollback
restart_policy:
condition: on-failure
delay: 5s
max_attempts: 3
window: 120s
networks:
- nameko-service

networks:
nameko-service:
driver: overlay
28 changes: 0 additions & 28 deletions src/pychassiscli/templates/nameko/docker-compose.yml

This file was deleted.

0 comments on commit 31a55f8

Please sign in to comment.