Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

label-printer: sometimes the printer stops printing #170

Open
tingox opened this issue Jun 7, 2022 · 5 comments
Open

label-printer: sometimes the printer stops printing #170

tingox opened this issue Jun 7, 2022 · 5 comments

Comments

@tingox
Copy link
Contributor

tingox commented Jun 7, 2022

A service for the label printeris created as a docker container, see #168. Sometimes the printer stops printing labels, and restarting the service helps:

tingo@heim:~$ sudo systemctl restart docker-service-p2k16-label-server
sudo: unable to resolve host heim: Name or service not known

before the service is restarted, it is not possible to see that there is anything wrong with it

tingo@heim:~$ systemctl status docker-service-p2k16-label-server
● docker-service-p2k16-label-server.service - Docker service: p2k16-label-server
     Loaded: loaded (/etc/systemd/system/docker-service-p2k16-label-server.service; enabled; vendor preset: enabled)
     Active: active (exited) since Sat 2022-05-07 14:07:31 CEST; 1 months 0 days ago
    Process: 1379 ExecStartPre=/usr/bin/docker-compose pull (code=exited, status=0/SUCCESS)
    Process: 1571 ExecStart=/usr/bin/docker-compose up -d (code=exited, status=0/SUCCESS)
   Main PID: 1571 (code=exited, status=0/SUCCESS)
        CPU: 1.627s

May 07 14:07:24 heim systemd[1]: Starting Docker service: p2k16-label-server...
May 07 14:07:28 heim docker-compose[1379]: Pulling p2k16-label ...
May 07 14:07:29 heim docker-compose[1379]: [259B blob data]
May 07 14:07:30 heim docker-compose[1571]: Starting p2k16-label-server_p2k16-label_1 ...
May 07 14:07:31 heim docker-compose[1571]: [64B blob data]
May 07 14:07:31 heim systemd[1]: Finished Docker service: p2k16-label-server.

it looks the same after it is restarted

tingo@heim:~$ systemctl status docker-service-p2k16-label-server
● docker-service-p2k16-label-server.service - Docker service: p2k16-label-server
     Loaded: loaded (/etc/systemd/system/docker-service-p2k16-label-server.service; enabled; vendor preset: enabled)
     Active: active (exited) since Tue 2022-06-07 21:22:16 CEST; 2s ago
    Process: 1192842 ExecStartPre=/usr/bin/docker-compose pull (code=exited, status=0/SUCCESS)
    Process: 1192844 ExecStart=/usr/bin/docker-compose up -d (code=exited, status=0/SUCCESS)
   Main PID: 1192844 (code=exited, status=0/SUCCESS)
        CPU: 1.243s

Jun 07 21:22:14 heim systemd[1]: Starting Docker service: p2k16-label-server...
Jun 07 21:22:14 heim docker-compose[1192842]: Pulling p2k16-label ...
Jun 07 21:22:15 heim docker-compose[1192842]: [259B blob data]
Jun 07 21:22:16 heim docker-compose[1192844]: Starting p2k16-label-server_p2k16-label_1 ...
Jun 07 21:22:16 heim docker-compose[1192844]: [64B blob data]
Jun 07 21:22:16 heim systemd[1]: Finished Docker service: p2k16-label-server.

Perhaps we should change the way p2k16 talks to the service; it could ask "hello, are you there?" and expect an answer "yes, I'm ready" before trying to print, That way it would be possible to show an error message to the user if the service doesn't respond.
(if we want end-to-end checking, the service should probably talk to the printer before accepting print jobs as well)

@omega
Copy link
Contributor

omega commented Jun 7, 2022

Could we do something like https://www.baeldung.com/linux/systemd-service-periodic-restart and just restart the service every night at 3 am or something?

@tingox
Copy link
Contributor Author

tingox commented Jun 8, 2022

Could we do something like https://www.baeldung.com/linux/systemd-service-periodic-restart and just restart the service every night at 3 am or something?

Yes, we could. But I prefer to fix the problem (root cause) instead. If we just "paper over" issues we will soon have a long list of jobs that do nothing but restart services, and after a few months nobody will remember why.

@tingox
Copy link
Contributor Author

tingox commented Aug 28, 2023

I had to restart ther service today again. Before:

tingo@heim:~$ systemctl status docker-service-p2k16-label-server
● docker-service-p2k16-label-server.service - Docker service: p2k16-label-server
     Loaded: loaded (/etc/systemd/system/docker-service-p2k16-label-server.service; enabled; vendor preset: enabled)
     Active: active (exited) since Thu 2023-08-24 20:33:22 CEST; 3 days ago
    Process: 1212 ExecStartPre=/usr/bin/docker-compose pull (code=exited, status=0/SUCCESS)
    Process: 1293 ExecStart=/usr/bin/docker-compose up -d (code=exited, status=0/SUCCESS)
   Main PID: 1293 (code=exited, status=0/SUCCESS)
        CPU: 1.914s

Aug 24 20:33:16 heim systemd[1]: Starting Docker service: p2k16-label-server...
Aug 24 20:33:18 heim docker-compose[1212]: Pulling p2k16-label ...
Aug 24 20:33:19 heim docker-compose[1212]: [259B blob data]
Aug 24 20:33:20 heim docker-compose[1293]: Starting p2k16-label-server_p2k16-label_1 ...
Aug 24 20:33:22 heim docker-compose[1293]: [64B blob data]
Aug 24 20:33:22 heim systemd[1]: Finished Docker service: p2k16-label-server.
tingo@heim:~$ sudo docker ps
CONTAINER ID   IMAGE                                          COMMAND   CREATED       STATUS      PORTS     NAMES
aaffb7c4e78d   ghcr.io/home-assistant/home-assistant:stable   "/init"   2 weeks ago   Up 3 days             homeassistant

after:

tingo@heim:~$ systemctl status docker-service-p2k16-label-server
● docker-service-p2k16-label-server.service - Docker service: p2k16-label-server
     Loaded: loaded (/etc/systemd/system/docker-service-p2k16-label-server.service; enabled; vendor preset: enabled)
     Active: active (exited) since Mon 2023-08-28 19:43:07 CEST; 3s ago
    Process: 349886 ExecStartPre=/usr/bin/docker-compose pull (code=exited, status=0/SUCCESS)
    Process: 349888 ExecStart=/usr/bin/docker-compose up -d (code=exited, status=0/SUCCESS)
   Main PID: 349888 (code=exited, status=0/SUCCESS)
        CPU: 1.287s

Aug 28 19:43:04 heim systemd[1]: Starting Docker service: p2k16-label-server...
Aug 28 19:43:04 heim docker-compose[349886]: Pulling p2k16-label ...
Aug 28 19:43:05 heim docker-compose[349886]: [259B blob data]
Aug 28 19:43:06 heim docker-compose[349888]: Starting p2k16-label-server_p2k16-label_1 ...
Aug 28 19:43:07 heim docker-compose[349888]: [64B blob data]
Aug 28 19:43:07 heim systemd[1]: Finished Docker service: p2k16-label-server.
tingo@heim:~$ sudo docker ps
CONTAINER ID   IMAGE                                          COMMAND                  CREATED         STATUS         PORTS     NAMES
aaffb7c4e78d   ghcr.io/home-assistant/home-assistant:stable   "/init"                  2 weeks ago     Up 3 days                homeassistant
59449f830943   ghcr.io/bitraf/p2k16-label:latest              "python print_label_…"   22 months ago   Up 7 seconds             p2k16-label-server_p2k16-label_1

@eliasbakken
Copy link
Contributor

The container died again pretty quickly. Here is the log:
image

@eliasbakken
Copy link
Contributor

lol, sorry, it was me that stopped the container by attaching to it. That is why it stopped by KeyboardInterrupt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants