What's the best way to get an application to auto re-launch when it crashes?

I am using ‘latte-dock’ from the /extra repo for my dock, and unfortunately it does crash here and there and can be a tad annoying to have to manually relaunch it every time. I won’t ask if there is a way because of course this is Linux, there always seems to be. But instead, ill ask what is the best way to accomplish this, and how would I do that? I’m going to take a wild guess and assume a script has to be written that keeps checking to see if latte is running and if it isnt, it will launch it. Too bad I have no idea how to write that. :innocent:

I use KDE Plasma btw.

I don’t use latte-dock-git, but the best solution for this is to track down the error in the logs and fix the problem.

2 Likes

@Kundalini
If you still accept this non-supported application and reluctant to dig into debug lists,
yay -S daemon
and replace latte-dock in Autostart with this

Which logs specifically will show why it’s crashing? How do I view it?

there is a tool in the distro called eos-log-tool start using and becoming familiar with it and the different logs

1 Like

Oooh nice. An all-in-one log tool. :+1:

1 Like

For what it’s worth I use latte-dock from the extra repo on EOS Plasma and it never crashes.
You should try it.

That’s actually the version that was crashing on me. I switched to the git version in the AUR and so far no crashes. Hopefully it remains stable.

So you confuse me. First you said that it was the AUR version that crashed, now the opposite…

That was an error. I should edit that. After I double-checked I realized it was from the /extra applications which belong to the main repo from my understanding. I mistakenly assumed AUR only because I used the yay command which I normally do for AURS whereas I normally would use pacman -S for main repo stuff. My mistake

If you cannot fix the error and the crash is “not too often” then you can just run it as systemd service. It is already part of your system.
Every time the service crashes systemd tries to restart it. If it crashes too soon after the restart it just gives up and keep it crashed so that the computer is not swamped by a bad service.

I do not know latte-dock and how it does what it does so maybe this is not applicable.

What’s this doing exactly?

It just crashed. I launched the log-tool, and I am fairly confident I selected all the relevant logs to share to identify the issue

http://ix.io/4LHG

Honestly you need to take the time to learn about the different logs and what information they give you. The logs you posted have a bunch of information that really isn’t needed or necessary to help with the issue. This is going to make it much harder for someone to be able to help you because now you have them looking and sorting through a bunch of irrelevant information.

I actually did go through this a couple of times before, and it proved useful, but it’s hard for me to memorize some stuff. Lots to absorb

This is ChatGPT’s solution to keeping ‘latte-dock-git’ open if it crashes. An auto restart script.

Automating the restart of latte-dock-git when it crashes can be achieved by creating a simple script and using a tool like systemd to manage the process. Here’s a step-by-step guide:

  1. Create a Script:
    Open your preferred text editor and create a script to restart latte-dock-git. For example, you can create a script named restart_latte.sh:

    #!/bin/bash
    
    while true; do
        latte-dock-git
    
        # Sleep for a short duration before restarting to avoid high CPU usage
        sleep 2
    done
    

    Save the script and make it executable:

    chmod +x restart_latte.sh
    
  2. Create a systemd Service:
    Now, you’ll create a systemd service that will run this script. Create a service file, e.g., latte-dock.service, in the /etc/systemd/system/ directory:

    [Unit]
    Description=Latte Dock Restarter
    
    [Service]
    ExecStart=/path/to/restart_latte.sh
    Restart=always
    User=your_username
    
    [Install]
    WantedBy=default.target
    

    Make sure to replace /path/to/restart_latte.sh with the actual path to your script and replace your_username with your actual username.

  3. Enable and Start the Service:
    Once the service file is created, reload the systemd manager configuration:

    sudo systemctl daemon-reload
    

    Enable the service to start on boot:

    sudo systemctl enable latte-dock.service
    

    Start the service:

    sudo systemctl start latte-dock.service
    

    Now, the service will restart latte-dock-git automatically if it crashes.

  4. Check the Status:
    You can check the status of the service to see if it’s running without issues:

    sudo systemctl status latte-dock.service
    

    This command will display information about the service, including whether it’s active and any recent log output.

This setup should provide a basic mechanism to automatically restart latte-dock-git if it crashes. If you encounter any issues or want more advanced configuration, you may need to adjust the script or systemd service accordingly.

thats why i said take the time to learn the different ones. fstab for instance was not needed as it has nothing to do with applications. I would start with something like xsession errors and xorg logs.

2 Likes

Or start from terminal window
latte-dock -d
and the ruins / log can be seen there. But it is not developed any more.
I repeat: having installed daemon
daemon -r /usr/bin/latte-dock
can be put into Autostart ( -r, --respawn - Respawn the client when it terminates)

Do you really want to trust something artificial with your OS?

1 Like