Open ajzozakiewicz opened 4 years ago
I need this too.
I need this too. Only way to do is to restart the mesh serve process and that will not be so nice once its deployed to production :/
Right now I'm using mesh in front of Hasura, I have them both running in local for development.
What I do is :
mesh dev
(using nodemon and rebuilding a file does the job)mesh dev
is rebooted and healthy, I run a graphql-codegen
command to introspect the schema and generate my schema.graphql
schema.graphql
changed, all my codegen pipeline is triggered βοΈ The scripts look like this :
"graphql-codegen:get-schema": "concurrently yarn:graphql-codegen:get-schema-*",
"graphql-codegen:on-hasura-change": "chokidar \"packages/server/hasura/**/*\" --command \"yarn workspace @clovis/server run proxy:reload && yarn graphql-codegen:get-schema\" --silent",
"proxy:dev": "nodemon --watch .meshrc.yml --watch src/app/proxy --exec yarn proxy:start",
"proxy:start": "wait-port http://localhost:8080/healthz && mesh dev --dir src/app/proxy --require dotenv/config",
"proxy:reload": "cat .meshrc.yml | tee .meshrc.yml > /dev/null",
To simplify everything it would be awesome if mesh dev
could poll for remote schema changes and automatically generate the schema.graphql
. π
I know this is not ideal, but here is another approach using Docker and Kubernetes. In my Dockerfile
, I wrote:
FROM node:16.13-alpine
# ...
RUN npm i -g pm2
# ...
ENTRYPOINT ["/bin/sh", "/app/update-schemas.sh"]
CMD pm2-runtime '/app/node_modules/.bin/mesh start' --no-autorestart --wait-ready --name mesh --listen-timeout 15000
Then in my update-schemas.sh
:
nohup sh -c "sleep 60 && yarn mesh build && pm2 reload all"
export $NEXT_RESTART_MINUTE=`date +"%M"`
echo "$NEXT_RESTART_MINUTE * * * * cd /app && yarn mesh build && pm2 reload all" >> /etc/crontab/root
crond -l 2 -f > /dev/stdout 2> /dev/stderr &
exec "$@"
What's happening here:
pm2
? Because if I kill the mesh process directly, my docker container diesyarn mesh start
in my CMD
line? Because otherwise pm2 wasn't able to kill the old mesh process.A few gotchas:
It is possible to have the mesh gateway poll running services for schema changes? Or trigger it to reload its sources somehow?
Current code snippet I am experimenting with: