jlesage / docker-jdownloader-2

Docker container for JDownloader 2
MIT License
783 stars 71 forks source link

[Bug] Container restarts after initial start #190

Closed Dual-0 closed 8 months ago

Dual-0 commented 9 months ago

Current Behavior

When I start the container for the first time via ansible and podman the container restarts after 2 minutes. see 10:36:20

Expected Behavior

The container shouldn't restart after 2 minutes.

Steps To Reproduce

Run Ansible Task:

- name: Create JDownloader2 container with systemd service
  become: true
  become_user: "{{ main_user }}"
  containers.podman.podman_container:
    name: jdownloader2
    image: docker.io/jlesage/jdownloader-2
    state: present
    publish:
      - "{{ container_host_ip }}:{{ container_jdownloader_web_port }}:5800" # Webinterface
      - "{{ container_host_ip }}:3129:3129" # My.jdownloader
      - "{{ container_host_ip }}:9666:9666" # Click'n'Load
    volume:
      - "{{ container_jdownloader_config_dir }}:/config:rw"
      - "{{ jdownloader_download_dir }}:/output:rw"
    generate_systemd:
      path: "{{ container_systemd_dir }}"
      restart_policy: always
    env:
      USER_ID: 0
      GROUP_ID: 0
      MYJDOWNLOADER_EMAIL: "{{ vault_myjdownloader_email }}"
      MYJDOWNLOADER_PASSWORD: "{{ vault_myjdownloader_password }}"
      MYJDOWNLOADER_DEVICE_NAME: "{{ ansible_hostname }}"

- name: JDownloader2 container must be started and enabled on systemd
  become: true
  become_user: "{{ main_user }}"
  systemd_service:
    name: container-jdownloader2
    daemon_reload: true
    state: started
    enabled: true
    scope: user

Environment

Container creation

- name: Create JDownloader2 container with systemd service
  become: true
  become_user: "{{ main_user }}"
  containers.podman.podman_container:
    name: jdownloader2
    image: docker.io/jlesage/jdownloader-2
    state: present
    publish:
      - "{{ container_host_ip }}:{{ container_jdownloader_web_port }}:5800" # Webinterface
      - "{{ container_host_ip }}:3129:3129" # My.jdownloader
      - "{{ container_host_ip }}:9666:9666" # Click'n'Load
    volume:
      - "{{ container_jdownloader_config_dir }}:/config:rw"
      - "{{ jdownloader_download_dir }}:/output:rw"
    generate_systemd:
      path: "{{ container_systemd_dir }}"
      restart_policy: always
    env:
      USER_ID: 0
      GROUP_ID: 0
      MYJDOWNLOADER_EMAIL: "{{ vault_myjdownloader_email }}"
      MYJDOWNLOADER_PASSWORD: "{{ vault_myjdownloader_password }}"
      MYJDOWNLOADER_DEVICE_NAME: "{{ ansible_hostname }}"

Container log

podman logs jdownloader2
2023-12-25T10:33:52.657978000Z [init        ] container is starting...
2023-12-25T10:33:52.658650000Z [cont-env    ] loading container environment variables...
2023-12-25T10:33:52.663122000Z [cont-env    ] APP_NAME: loading...
2023-12-25T10:33:52.668222000Z [cont-env    ] DISPLAY: executing...
2023-12-25T10:33:52.675663000Z [cont-env    ] DISPLAY: terminated successfully.
2023-12-25T10:33:52.676551000Z [cont-env    ] DISPLAY: loading...
2023-12-25T10:33:52.679326000Z [cont-env    ] DOCKER_IMAGE_PLATFORM: loading...
2023-12-25T10:33:52.684331000Z [cont-env    ] DOCKER_IMAGE_VERSION: loading...
2023-12-25T10:33:52.689762000Z [cont-env    ] GTK2_RC_FILES: executing...
2023-12-25T10:33:52.698384000Z [cont-env    ] GTK2_RC_FILES: terminated successfully.
2023-12-25T10:33:52.699127000Z [cont-env    ] GTK2_RC_FILES: loading...
2023-12-25T10:33:52.701769000Z [cont-env    ] GTK_THEME: executing...
2023-12-25T10:33:52.710880000Z [cont-env    ] GTK_THEME: terminated successfully.
2023-12-25T10:33:52.711626000Z [cont-env    ] GTK_THEME: loading...
2023-12-25T10:33:52.714010000Z [cont-env    ] HOME: loading...
2023-12-25T10:33:52.718047000Z [cont-env    ] INSTALL_PACKAGES_INTERNAL: executing...
2023-12-25T10:33:52.722684000Z [cont-env    ] INSTALL_PACKAGES_INTERNAL: terminated successfully.
2023-12-25T10:33:52.723306000Z [cont-env    ] INSTALL_PACKAGES_INTERNAL: loading...
2023-12-25T10:33:52.725560000Z [cont-env    ] QT_STYLE_OVERRIDE: executing...
2023-12-25T10:33:52.732326000Z [cont-env    ] QT_STYLE_OVERRIDE: terminated successfully.
2023-12-25T10:33:52.733073000Z [cont-env    ] QT_STYLE_OVERRIDE: loading...
2023-12-25T10:33:52.735485000Z [cont-env    ] TAKE_CONFIG_OWNERSHIP: loading...
2023-12-25T10:33:52.740395000Z [cont-env    ] XDG_CACHE_HOME: loading...
2023-12-25T10:33:52.744081000Z [cont-env    ] XDG_CONFIG_HOME: loading...
2023-12-25T10:33:52.747916000Z [cont-env    ] XDG_DATA_HOME: loading...
2023-12-25T10:33:52.752338000Z [cont-env    ] XDG_RUNTIME_DIR: loading...
2023-12-25T10:33:52.756350000Z [cont-env    ] XDG_STATE_HOME: loading...
2023-12-25T10:33:52.759519000Z [cont-env    ] container environment variables initialized.
2023-12-25T10:33:52.759702000Z [cont-secrets] loading container secrets...
2023-12-25T10:33:52.759847000Z [cont-secrets] container secrets loaded.
2023-12-25T10:33:52.760026000Z [cont-init   ] executing container initialization scripts...
2023-12-25T10:33:52.763514000Z [cont-init   ] 10-certs.sh: executing...
2023-12-25T10:33:52.769919000Z [cont-init   ] 10-certs.sh: terminated successfully.
2023-12-25T10:33:52.772169000Z [cont-init   ] 10-check-app-niceness.sh: executing...
2023-12-25T10:33:52.776056000Z [cont-init   ] 10-check-app-niceness.sh: terminated successfully.
2023-12-25T10:33:52.777963000Z [cont-init   ] 10-clean-logmonitor-states.sh: executing...
2023-12-25T10:33:52.782786000Z [cont-init   ] 10-clean-logmonitor-states.sh: terminated successfully.
2023-12-25T10:33:52.785055000Z [cont-init   ] 10-clean-tmp-dir.sh: executing...
2023-12-25T10:33:52.790489000Z [cont-init   ] 10-clean-tmp-dir.sh: terminated successfully.
2023-12-25T10:33:52.793007000Z [cont-init   ] 10-fontconfig-cache-dir.sh: executing...
2023-12-25T10:33:52.798242000Z [cont-init   ] 10-fontconfig-cache-dir.sh: terminated successfully.
2023-12-25T10:33:52.800334000Z [cont-init   ] 10-init-users.sh: executing...
2023-12-25T10:33:52.840757000Z [cont-init   ] 10-init-users.sh: terminated successfully.
2023-12-25T10:33:52.842628000Z [cont-init   ] 10-nginx.sh: executing...
2023-12-25T10:33:52.880857000Z [cont-init   ] 10-nginx.sh: terminated successfully.
2023-12-25T10:33:52.882611000Z [cont-init   ] 10-openbox.sh: executing...
2023-12-25T10:33:52.921708000Z [cont-init   ] 10-openbox.sh: terminated successfully.
2023-12-25T10:33:52.923655000Z [cont-init   ] 10-pkgs-mirror.sh: executing...
2023-12-25T10:33:52.928189000Z [cont-init   ] 10-pkgs-mirror.sh: terminated successfully.
2023-12-25T10:33:52.930659000Z [cont-init   ] 10-set-tmp-dir-perms.sh: executing...
2023-12-25T10:33:52.935577000Z [cont-init   ] 10-set-tmp-dir-perms.sh: terminated successfully.
2023-12-25T10:33:52.937576000Z [cont-init   ] 10-vnc-password.sh: executing...
2023-12-25T10:33:52.942064000Z [cont-init   ] 10-vnc-password.sh: terminated successfully.
2023-12-25T10:33:52.944023000Z [cont-init   ] 10-web-data.sh: executing...
2023-12-25T10:33:52.954531000Z [cont-init   ] 10-web-data.sh: terminated successfully.
2023-12-25T10:33:52.956559000Z [cont-init   ] 10-x11-unix.sh: executing...
2023-12-25T10:33:52.962644000Z [cont-init   ] 10-x11-unix.sh: terminated successfully.
2023-12-25T10:33:52.965022000Z [cont-init   ] 10-xdg-runtime-dir.sh: executing...
2023-12-25T10:33:52.975024000Z [cont-init   ] 10-xdg-runtime-dir.sh: terminated successfully.
2023-12-25T10:33:52.976769000Z [cont-init   ] 15-cjk-font.sh: executing...
2023-12-25T10:33:52.984439000Z [cont-init   ] 15-cjk-font.sh: terminated successfully.
2023-12-25T10:33:52.986300000Z [cont-init   ] 15-install-pkgs.sh: executing...
2023-12-25T10:33:52.990097000Z [cont-init   ] 15-install-pkgs.sh: terminated successfully.
2023-12-25T10:33:52.991751000Z [cont-init   ] 55-jdownloader2.sh: executing...
2023-12-25T10:33:53.150735000Z [cont-init   ] 55-jdownloader2.sh: terminated successfully.
2023-12-25T10:33:53.152205000Z [cont-init   ] 85-take-config-ownership.sh: executing...
2023-12-25T10:33:53.173223000Z [cont-init   ] 85-take-config-ownership.sh: terminated successfully.
2023-12-25T10:33:53.175344000Z [cont-init   ] 89-info.sh: executing...
2023-12-25T10:33:53.179325000Z     ╭――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――╮
2023-12-25T10:33:53.180741000Z     │                                                                      │
2023-12-25T10:33:53.182139000Z     │ Application:           JDownloader 2                                 │
2023-12-25T10:33:53.183086000Z     │ Application Version:   n/a                                           │
2023-12-25T10:33:53.184542000Z     │ Docker Image Version:  23.11.2                                       │
2023-12-25T10:33:53.185610000Z     │ Docker Image Platform: linux/arm64                                   │
2023-12-25T10:33:53.186655000Z     │                                                                      │
2023-12-25T10:33:53.187924000Z     ╰――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――╯
2023-12-25T10:33:53.189316000Z [cont-init   ] 89-info.sh: terminated successfully.
2023-12-25T10:33:53.189987000Z [cont-init   ] all container initialization scripts executed.
2023-12-25T10:33:53.193513000Z [init        ] giving control to process supervisor.
2023-12-25T10:33:53.210720000Z [supervisor  ] loading services...
2023-12-25T10:33:53.210968000Z [supervisor  ] loading service 'default'...
2023-12-25T10:33:53.212619000Z [supervisor  ] loading service 'app'...
2023-12-25T10:33:53.225095000Z [supervisor  ] loading service 'gui'...
2023-12-25T10:33:53.225341000Z [supervisor  ] loading service 'certsmonitor'...
2023-12-25T10:33:53.229719000Z [supervisor  ] service 'certsmonitor' is disabled.
2023-12-25T10:33:53.229903000Z [supervisor  ] loading service 'nginx'...
2023-12-25T10:33:53.230021000Z [supervisor  ] loading service 'xvnc'...
2023-12-25T10:33:53.247058000Z [supervisor  ] loading service 'openbox'...
2023-12-25T10:33:53.247251000Z [supervisor  ] loading service 'logmonitor'...
2023-12-25T10:33:53.250245000Z [supervisor  ] service 'logmonitor' is disabled.
2023-12-25T10:33:53.250385000Z [supervisor  ] loading service 'logrotate'...
2023-12-25T10:33:53.257862000Z [supervisor  ] all services loaded.
2023-12-25T10:33:53.258037000Z [supervisor  ] starting services...
2023-12-25T10:33:53.258153000Z [supervisor  ] starting service 'xvnc'...
2023-12-25T10:33:53.361654000Z [xvnc        ] Xvnc TigerVNC 1.13.1 - built Nov 17 2023 22:53:35
2023-12-25T10:33:53.361891000Z [xvnc        ] Copyright (C) 1999-2022 TigerVNC Team and many others (see README.rst)
2023-12-25T10:33:53.362014000Z [xvnc        ] See https://www.tigervnc.org for information on TigerVNC.
2023-12-25T10:33:53.362154000Z [xvnc        ] Underlying X server release 12014000
2023-12-25T10:33:53.373848000Z [xvnc        ] Mon Dec 25 10:33:53 2023
2023-12-25T10:33:53.374000000Z [xvnc        ]  vncext:      VNC extension running!
2023-12-25T10:33:53.375663000Z [xvnc        ]  vncext:      Listening for VNC connections on /tmp/vnc.sock (mode 0660)
2023-12-25T10:33:53.375838000Z [xvnc        ]  vncext:      Listening for VNC connections on all interface(s), port 5900
2023-12-25T10:33:53.384568000Z [xvnc        ]  vncext:      created VNC server for screen 0
2023-12-25T10:33:53.789169000Z [supervisor  ] starting service 'nginx'...
2023-12-25T10:33:53.792888000Z [nginx       ] Listening for HTTP connections on port 5800.
2023-12-25T10:33:54.295326000Z [supervisor  ] starting service 'openbox'...
2023-12-25T10:33:54.797384000Z [supervisor  ] starting service 'app'...
2023-12-25T10:33:55.298196000Z [supervisor  ] all services started.
2023-12-25T10:34:29.733354000Z [xvnc        ] Mon Dec 25 10:34:29 2023
2023-12-25T10:34:29.734085000Z [xvnc        ]  Connections: accepted: /tmp/vnc.sock
2023-12-25T10:34:29.782487000Z [xvnc        ]  SConnection: Client needs protocol version 3.8
2023-12-25T10:34:29.827218000Z [xvnc        ]  SConnection: Client requests security type None(1)
2023-12-25T10:34:29.832504000Z [xvnc        ]  VNCSConnST:  Server default pixel format depth 24 (32bpp) little-endian rgb888
2023-12-25T10:34:29.922303000Z [xvnc        ]  VNCSConnST:  Client pixel format depth 24 (32bpp) little-endian bgr888
2023-12-25T10:34:29.977629000Z [xvnc        ]  ComparingUpdateTracker: 0 pixels in / 0 pixels out
2023-12-25T10:34:29.977885000Z [xvnc        ]  ComparingUpdateTracker: (1:nan ratio)
2023-12-25T10:36:20.924314000Z [supervisor  ] SIGTERM received, shutting down...
2023-12-25T10:36:20.926019000Z [app         ] Terminated
2023-12-25T10:36:20.926818000Z [openbox     ] X connection to :0 broken (explicit kill or server shutdown).
2023-12-25T10:36:20.930910000Z [xvnc        ] Mon Dec 25 10:36:20 2023
2023-12-25T10:36:20.931038000Z [xvnc        ]  VNCSConnST:  closing /tmp/vnc.sock: Server shutdown
2023-12-25T10:36:20.931101000Z [xvnc        ]  EncodeManager: Framebuffer updates: 241
2023-12-25T10:36:20.931177000Z [xvnc        ]  EncodeManager:   Tight:
2023-12-25T10:36:20.931257000Z [xvnc        ]  EncodeManager:     Solid: 180 rects, 9.98562 Mpixels
2023-12-25T10:36:20.931332000Z [xvnc        ]  EncodeManager:            2.8125 KiB (1:13869.7 ratio)
2023-12-25T10:36:20.931414000Z [xvnc        ]  EncodeManager:     Bitmap RLE: 30 rects, 25.669 kpixels
2023-12-25T10:36:20.931490000Z [xvnc        ]  EncodeManager:                 974 B (1:105.786 ratio)
2023-12-25T10:36:20.931574000Z [xvnc        ]  EncodeManager:     Indexed RLE: 421 rects, 478.379 kpixels
2023-12-25T10:36:20.931654000Z [xvnc        ]  EncodeManager:                  76.0771 KiB (1:24.6277 ratio)
2023-12-25T10:36:20.931721000Z [xvnc        ]  EncodeManager:   Tight (JPEG):
2023-12-25T10:36:20.931809000Z [xvnc        ]  EncodeManager:     Full Colour: 219 rects, 808.69 kpixels
2023-12-25T10:36:20.931876000Z [xvnc        ]  EncodeManager:                  533.778 KiB (1:5.92289 ratio)
2023-12-25T10:36:20.931939000Z [xvnc        ]  EncodeManager:   Total: 850 rects, 11.2984 Mpixels
2023-12-25T10:36:20.931997000Z [xvnc        ]  EncodeManager:          613.619 KiB (1:71.9407 ratio)
2023-12-25T10:36:20.932057000Z [xvnc        ]  ComparingUpdateTracker: 52.8312 Mpixels in / 8.34189 Mpixels out
2023-12-25T10:36:20.932116000Z [xvnc        ]  ComparingUpdateTracker: (1:6.33323 ratio)
2023-12-25T10:36:21.066969000Z [supervisor  ] SIGTERM received, shutting down...
2023-12-25T10:36:21.318947000Z [supervisor  ] stopping service 'app'...
2023-12-25T10:36:21.319195000Z [supervisor  ] service 'xvnc' exited (with status 0).
2023-12-25T10:36:21.319316000Z [supervisor  ] service 'nginx' exited (with status 0).
2023-12-25T10:36:21.319428000Z [supervisor  ] service 'openbox' exited (with status 1).
2023-12-25T10:36:21.319542000Z [supervisor  ] service 'app' exited (with status 143).
2023-12-25T10:36:21.323279000Z [finish      ] executing container finish scripts...
2023-12-25T10:36:21.325468000Z [finish      ] all container finish scripts executed.
2023-12-25T10:36:54.496198000Z [init        ] container is starting...
2023-12-25T10:36:54.496550000Z [cont-env    ] loading container environment variables...
...


### Container inspect

_No response_

### Anything else?

_No response_
jlesage commented 9 months ago

Looks like the container has been stopped explicitly ?

2023-12-25T10:36:20.924314000Z [supervisor  ] SIGTERM received, shutting down...
Dual-0 commented 9 months ago

Looks like the container has been stopped explicitly ?

2023-12-25T10:36:20.924314000Z [supervisor  ] SIGTERM received, shutting down...

I haven't done it manually

jlesage commented 9 months ago

Do you see anything useful from the host system log ? Somehow the container has been requested to be terminated.

Do you see the problem is you create/start the container yourself ?

Dual-0 commented 8 months ago

@jlesage you are right! The container was stopped automatically from systemd after the user (ansible) logs out.

I found the solution in the podman docs for systemd:

The systemd user instance is killed after the last session for the user is closed. The systemd user instance can be started at boot and kept running even after the user logs out by enabling lingering using

just enable lingering via loginctl enable-linger <username>

jlesage commented 8 months ago

Great, thanks for the update !