Skip to content

Commit 3d36e9f

Browse files
authored
Flame graph debugging
1 parent 381fec7 commit 3d36e9f

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ Database seeding is also handled by Prisma, with full documentation [here](https
144144
## Non-database storage
145145
It is generally recommended to store data on an external server, but for smaller projects, local upload/download can also be useful. In this project, admins have a wide array of customization features, such as changing the images in a hero banner. Uploaded data is stored at `<project_dir>`/assets
146146
147-
148147
## Remote debugging
149148
If you have scripts to back up the database or logs from a remote server, you probably want them to run automatically. This can be done through `Task Scheduling`.
150149
@@ -163,6 +162,20 @@ Sometimes, generating TypeScript will give a "JavaScript heap out of memory" err
163162
164163
If that doesn't solve this issue, you can debug TypeScript by changing `yarn tsc` to `yarn tsc --generate trace-data`. This will create a folder called `trace-data`, which contains a log that you can upload to `about://tracing` on Edge or Chrome. See [TypeScript's performance tracing guide](https://github.com/microsoft/TypeScript/wiki/Performance#performance-tracing) for more information.
165164
165+
## Server debugging
166+
When debugging the UI, we have a lot of options. There are console logs, Lighthouse testing, and [React Developer Tools](https://chrome.google.com/webstore/detail/react-developer-tools/fmkadmapgofadopljbjfkapdkoienihi). The server, on the other hand, is a bit more complicated.
167+
168+
The server also supports console logs, but they aren't available during production. Instead, we can look at logs. These are generated at `data/logs`. You can also track logs from a remote server, which is described in the *Remote debugging* section of this document.
169+
170+
For performance measuring, we can use the [0x profiling tool](https://github.com/davidmarkclements/0x) to generate flame graphs. Getting this to work with Docker is a little cumbersome, but the result is worth it. You have to:
171+
1. Change `nodemon` or `node` (depending on if you're calling the development or server script) to `0x --node`. Leave the arguments after the same.
172+
2. Start the project as normal. You should see a file named `isolate-<random_characters>.log`. This is not the flamegraph yet, but is used to generate it.
173+
3. Perform whatever test you need so that `0x` can gather data.
174+
4. To generate the flame graph, we have to stop the `0x` process manually. Start by entering the server container: `docker exec -it server sh`
175+
5. Enter `ps` and look for a process with `node` and `0x` in the name. Make note of the PID (the number on the left)
176+
6. Enter `kill -SIGINT <0x_PID>`. This will generate a folder called `<0x_PID.0x`.
177+
7. Open the `.html` file in the generated folder to view the flame graph
178+
166179
## Email setup
167180
It is often useful to send and receives emails with the website's address. Instructions to set that up can be found [here](/docs/MessengerSetup.txt)
168181

0 commit comments

Comments
 (0)