Master

Debugging an app that is running

The app that is broken is the app that is running. Reading it while it runs is a set of questions, and each question has an answer that is a number.

What you will see

One line with three names. The line is the record the fix is argued with.

About 1 min of reading

Try It

Write the three answers

1

Run the same request twice

printf 'test 200\nplace 502\n' > /tmp/q.txt; awk '{print $1, $2}' /tmp/q.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
test 200 then place 502. The difference is a layer, and the layer is the first answer.
2

Read the log for the route

printf 'POST /api/ping 502\n' > /tmp/g.txt; awk '{print $2, $3}' /tmp/g.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
/api/ping 502. Route and status together name the failure without a guess.
3

Write the record

printf 'layer=balancer route=/api/ping status=502 date=2026-10-10\n' > /tmp/r.txt; cat /tmp/r.txt

Before you run it, say out loud what it will print. Then open the answer.

What it prints
One line with three names. The line is the record the fix is argued with.

Data Flow

A failure to three answers
1 The same request is run in test and in place
↓
2 The layer difference is named
↓
3 The log is read for route and status
↓
4 The config printed at start is compared
Why this works
Why the three questions are ordered

Each one narrows the next. A layer that is wrong makes the log useless, so the layer is asked first.

The artefact of a debug run

The three answers in one file. The file is the record, and the record is what the fix is argued with.

Examples

The first question is which layer

The same request is answered twice, once in test and once in place. The difference is a layer, and the layer is the first answer.

The log is the second answer

The log names the route and the status. A log with both is a log that names the failure without a guess.

The state is the third

The app prints its config at start. Printing at start is printing what was given, which is the thing a reload changes.

Words this lesson uses

Each one is defined here on this site. Open the entry for the full definition and the other words it points at.

← Where a Flask app stops
Previous Lesson
Where a Flask app stops
Next Lesson
Deploying an app that must not break
Deploying an app that must not break →