Linux Labs

Inside the system: resources, kernel, processes / Stage 10 of 12

From GRUB to a target: how the system boots

Not running Starting usually ~20 s
Leave the lesson

Step 7 of 8 · lab · 25 minmedium

A service holds up the boot

After every reboot the warehouse waits for half a minute, and the order desk never comes up — someone starts it by hand later. A colleague insists the service dependencies are set up. Make the order desk come up on its own after a reboot without holding up the boot.

Situation

The warehouse server runs two services: the order desk lab-orders (http://127.0.0.1:8090) and the stock store lab-stock. At startup the order desk loads the stock levels from the store — without them it accepts no orders.

After every reboot the server takes half a minute longer to boot, and lab-orders ends up failed — the on-call admin brings the services up by hand later. A colleague insists the service dependencies are set up; the units are in /etc/systemd/system/.

The machine is now as it is after such a boot: lab-orders has just tried to start.

Task

  1. lab-orders starts the lab-stock store itself and starts after it: the dependencies live in its unit (Wants= and After=), with no reverse ordering.
  2. systemd-analyze verify lab-orders.service lab-stock.service prints no warnings.
  3. lab-orders is running, enabled at boot and answering: curl http://127.0.0.1:8090/health.
  4. After a reboot (sudo reboot) lab-orders comes up on its own at the first attempt and holds up the boot for no more than 10 seconds.

Constraints

  • Do not change the application code — /usr/local/bin/order-desk and /usr/local/bin/stock-store.
  • You may reboot the machine as often as you like: the terminal shows the boot and logs in as student again. "Check" looks at a boot that happened after the machine was prepared, so reboot it after your fix.

There is no internet on the machine; everything you need is installed. How the service starts is visible in systemctl status lab-orders and journalctl -u lab-orders; what holds up the boot — in systemd-analyze blame and systemd-analyze critical-chain.

Lab · on your own

No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.

Goals

0 of 4
  • lab-orders starts the lab-stock store itself and starts after it (Wants= and After=), with no reverse ordering — not done yet
  • systemd-analyze verify lab-orders.service lab-stock.service prints no warnings — not done yet
  • lab-orders is running, enabled at boot and answers on http://127.0.0.1:8090/health; the application code is unchanged — not done yet
  • After a reboot (sudo reboot) lab-orders came up on its own at the first attempt and held up the boot for no more than 10 s — not done yet
Ctrl+Enter
Starts the machine node1 · Ubuntu 24.04

The machine is starting

Hints

0 of 3

Lab goals

0 of 4
  • lab-orders starts the lab-stock store itself and starts after it (Wants= and After=), with no reverse ordering — not done yet
  • systemd-analyze verify lab-orders.service lab-stock.service prints no warnings — not done yet
  • lab-orders is running, enabled at boot and answers on http://127.0.0.1:8090/health; the application code is unchanged — not done yet
  • After a reboot (sudo reboot) lab-orders came up on its own at the first attempt and held up the boot for no more than 10 s — not done yet
node1 Ubuntu 24.04

Lab goals

0 of 4
  • lab-orders starts the lab-stock store itself and starts after it (Wants= and After=), with no reverse ordering — not done yet
  • systemd-analyze verify lab-orders.service lab-stock.service prints no warnings — not done yet
  • lab-orders is running, enabled at boot and answers on http://127.0.0.1:8090/health; the application code is unchanged — not done yet
  • After a reboot (sudo reboot) lab-orders came up on its own at the first attempt and held up the boot for no more than 10 s — not done yet
Loading…