Linux on call · Chapter 29 of 30
The 2 am page
By the end of this chapter you can bring a broken server back on your own: look first, stop what is causing the damage, free the space, and put the app back so that it stays up. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.
- Part: The 2 am page
- 4 tasks
- Linux
- In the all labs plan
The first 2 chapters of Linux on call are free. This one comes with the all labs plan.
Why you need this
Ravi's message, in RAVI.txt:
cat RAVI.txt
02:04 Ravi: the app is down and the disk alert says 97% full.
Orders open at 7. Please get the app back on 127.0.0.1:8029.
(Bunty says he 'only turned on a bit of logging')
Kabir is asleep. You have met every tool for this night: du and truncate (chapter 21), signals (chapter 19), nohup (chapter 20), chmod (chapter 14). What is new is doing them under pressure, in the right order. Empty the log while its writer runs, and it fills again. Delete a log a program holds open, and the disk stays full. Start the app before the space is back, and it refuses. Make the config readable with Bunty's favourite, chmod 777, and every user on the machine can read the payment key.
What you build: 4 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
Stop the debug logger that ignores a normal kill
Stop Bunty's debug logger. It keeps filling the disk.
1. Read RAVI.txt. Find the running process of tools/debug-logger.sh.
2. Ask it to stop the normal way. Then look again: it is still running.
3. Send it the signal that no process can ignore. Send it to that process only.
4. Look again to make sure it is gone.
To pass: tools/debug-logger.sh is not running any more.
- Task 2
Empty debug.log, and keep the other logs
Free the disk space that logs/debug.log takes.
1. Stop the logger first (task 1), or the log fills up again.
2. Empty logs/debug.log where it is. Do not delete it: the file stays, with nothing in it.
3. Do not touch logs/access.log and logs/app.log. Ravi needs them.
To pass: logs/debug.log is 1 MB or smaller, and logs/access.log and logs/app.log are still there.
- Task 3
Make config.env readable by you and nobody else
app/config.env has a payment key, and right now nobody can read it, not even you.
1. Run ls -l app to see the permissions of config.env.
2. Use chmod to give yourself read and write permission.
3. Give the group and others no permission at all.
4. Do not change what is inside the file, and do not change its owner.
To pass: you (student) still own app/config.env, and you can read it. The group and others have no permission on it. Its settings, like PORT=8029, are still inside.
- Task 4
Start the app again so it keeps running without your terminal
Start the app again, so orders can open at 7.
1. Do tasks 2 and 3 first. The app does not start while debug.log is big or config.env cannot be read.
2. In the chapter folder, start app/start.sh with nohup in front and & at the end.
3. Send both of its output streams to logs/app.log.
4. Wait a few seconds. Then ask http://127.0.0.1:8029/health with curl.
To pass: the app is running and answers ok on http://127.0.0.1:8029/health. You typed the nohup command in the chapter folder.
What you will learn
- Look before you touch: du, tail, ls -l and ps say what is wrong before you change anything.
- Stop the source first, then check that it really stopped.
- Free the space, keep the file: why emptying beats deleting.
- Put it back for good: a secrets file's permissions, and a server that outlives your terminal.
More in The 2 am page
Build The 2 am page yourself
Tapri’s ordering app moves onto a Linux server, and the server is now yours to run. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.
The first 2 chapters of Linux on call are free. This one comes with the all labs plan.