graphjin
graphjin copied to clipboard
debugging via docker and webui using gebug
What would you like to be added:
ability to debug the local and remote docker.
Why is this needed:
I think that its going to make it much easier for others to locate and fix bugs in the code, and hopefully then get higher quality PR's etc as well as devs self diagnosing.
I am using this https://github.com/moshebe/gebug and it works very well. i think its a good choice for integration into graphjin because all that is needed is a .gebug folder with the settlings in it.
The web ui is also useful. It also works with different IDE's. I use vscode with it.
The bash API looks like this:
then: gebug start {working dir}--skip-generate
then: gebug ui {working dir}--skip-generate
These are the 3 things used. gebug can generate them for you if you want.
config.yml:
name: ws
output_binary: /app
build_command: go build -o /app
build_dir: ""
run_command: /app
runtime_image: golang:1.15.2
debugger_enabled: true
debugger_port: 40000
expose_ports: []
networks: []
environment: []
docker:
FROM golang:1.15.2
RUN go get github.com/githubnemo/CompileDaemon
RUN go get github.com/go-delve/delve/cmd/dlv
WORKDIR /src
COPY . .
RUN go build -gcflags="all=-N -l" -o /app
ENTRYPOINT dlv --listen=:40000 --headless=true --api-version=2 --accept-multiclient exec /app
docker-compose.yml
version: '3'
services:
gebug-ws:
build:
context: ..
dockerfile: .gebug/Dockerfile
cap_add:
- SYS_PTRACE
volumes:
- ../:/src:ro
ports:
- 40000:40000
Interesting thanks I'll take a look. I'm up for adding this especially since it also handles the hot reload.
yeah i have been using it and its been really great.
i might have time to PR it in... I am still going through the code and wiki and working out things.
what do you think of the idea to add pgadmin to the docker also ? It will make it much easier for devs to see what's going on, and to help fix bugs.
I normally do this on postgres based projects so i can easily see what my code is doing under the hood.
something like this: https://blog.crunchydata.com/blog/easy-postgresql-12-and-pgadmin-4-setup-with-docker.
That sounds like a great idea as well go ahead.
Let me know if there is anything I can help with in regards to this?
hey @dosco
Sorry about such a long delay. you know life !!
I have been thinking about this, whilst working on other projects and finally have time again. I came up with a totally different approach to how provide extended functionality with graph jin.
Its quite easy to build a basic DB Admin with golang these days. Using golang allows:
- compile time safety
- ability to reuse the code in graphJin
Here is the type of functionality i am thinking about. Some of it is a bit ambituous, and it can built overtime of course.
The main thing is that the Golang Admin GUI uses graphql to interact with graphJin - Maximise reuse and existing functionality. Subscriptions in graphJin gives us a GUI that updates in response to changes, so that for example if you run a migration, the GUI updates. Pretty cool and intuitive.
Some of the functionality could then be:
- migrations. You can write them in the GUI and validate them.
- Tables
- Queries
- Users and Roles. Both at the DB level, but also we could introduce application level ones so that different users can do different things to graphJin.
- white list control. WIth the User and Roles, then lots of opportunities open up for whilelist control. We could use tags to group whitelists to certain teams using the system. Teams can be Dev Teams but also Users ( i mean the end users ).
- Logic. Currently this is done with JS. We would use golang and the jaeger VM. I have a GUI and Server using it and it works. So you can write and test the logic all in the gui, before saving to the graphjib server.
- Json Schema for validation. This unifies validation checking, and allows the Logic layer to reuse it IFit wants, and json schema is extensible too. It's also very easy to gen the SQL migration scripts from jsonschema. SO we can get validation logic at both levels using the exact same mechanism.
- GraphQL Explorer. I knowthat the current one is in JS, but i think a golang one will make it easier to tap into all the other things above. The things above are all cross cutting to the GraphQL explore, and so i feel there is a way to leverage the two together. I think that what those are is probably not fully known yet. I reckon that you might have some ideas here ...
SO what this really ends up being is a type of IDE and Gateway in that you can admin, but also customise on top of graphqlJin in a unified way.
I know this is rather a big step.
I already have something basic working but i hit a problem with the websockets lib that graphJib uses. https://github.com/nhooyr/websocket is what i use and its great because i can compile the golang gui to wasm and it works great. But graphJib uses github.com/gorilla/websocket
I also swapped over to using https://github.com/buger/jsonparser
Faster on the server. Dont need to know the types at compile time. Allows the golang based GUI to work when compiled to wasm.
Its used a fair bit : https://github.com/search?l=Go&o=desc&q=github.com%2Fbuger%2Fjsonparser&s=indexed&type=Code
This is a good example: https://github.com/jensneuse/graphql-go-tools that uses it. It is graphql gateway / federation system. This is the same also: https://github.com/TykTechnologies/graphql-go-tools