The port change that did not stick INC-2512

OpenNo account needed2 versionsLinux · Easy · Fix · about 20 min ·Linux

Lab machine

A private Linux machine with the problem already set up. Sessions last up to 60 minutes.
Tomas Berg opened INC-2512 at 03:58SEV-3

The depot-4 printers moved to port 9105 overnight. Tomas changed the spooler's port in its unit and restarted it twice. It still listens on 9100, and the 06:00 trucks need their labels.

Every parcel leaving depot-4 needs a printed label. The new printer firmware sends jobs to port 9105, so until the spooler moves, nothing prints.

"Changed it in the unit, restarted twice. Status says active. Printers still say connection refused on 9105. I'm off at 04:00, sorry." (Tomas, 03:40)

The host runs a small service manager (bin/hostctl, behaves like systemctl) with a journal (bin/hostlog, like journalctl). Tomas did change the unit file. Find out why the running spooler never saw it.

Your task

Move the label spooler to 127.0.0.4:9105 so that the running process, a restart, and a reboot all agree, and leave the configuration in a state the next person can read.

On the machine

  • bin/hostctl status label-spooler, bin/hostlog -u label-spooler -b
  • etc/units/label-spooler.service and etc/default/label-spooler
  • home/tomas/.bash_history
  • curl -s http://127.0.0.4:9100/healthz reports the address the spooler listens on

Timeline

02:30New label printer firmware on depot-4 switches print jobs to port 9105.
03:10Tomas edits label-spooler.service and restarts it twice.
03:40"Status says active. Printers still say connection refused on 9105."
05:15INC-2512 lands with you. The first trucks leave at 06:00.

Done when

  1. label-spooler answers on 127.0.0.4:9105 under the service manager, and 9100 is closed.
  2. It comes back on 9105 after a reboot.
  3. The service manager has loaded the unit file that is on disk.
  4. The port is not set to different values in different places.

Hints

Hint 1

`bin/hostctl status` warns when the unit file on disk is newer than what is loaded.

Hint 2

After a daemon-reload, check which port the spooler actually got. The journal prints it.

Hint 3

Read the whole unit. One setting can be given in more than one place.

Hint 4

In systemd, a value from EnvironmentFile= overrides the same name in Environment=, and a program may prefer its command-line flags over both.

Show the solution

Set `SPOOL_PORT=9105` in `etc/default/label-spooler` (the file meant for local changes) and remove SPOOL_PORT from the unit's Environment= line or set it to 9105 there too. Run `bin/hostctl daemon-reload`, then `bin/hostctl restart label-spooler`, and confirm with `curl http://127.0.0.4:9105/healthz`.