I want to launch Oobabooga Textgen WebUI from the command line with its serial output. I also want to run a while loop that retrieves the Nvidia GPU memory available and temperature for display on the header bar with a 5 second sleep delay. How do I run both of those at the same time?

  • future_turtle@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    8 months ago

    You probably want to make a launcher script. An easy start would be to background your main process and route the output wherever you want. Run your monitor loop and send the output wherever you want. Then you can examine and kill the main background pid on script exit. The simplest way in bash might be something like kill $(jobs -p)

    This can get a bit more complicated if you want it all to exit if anything fails or something like that. Read up on pkill, disown, kill, $$, trap…tons of possibilities

    Some of these things aren’t very portable though, so do check if you decide to switch shells….or do what the rest of us do and scratch your head for an hour before cussing ourselves for not being posix compliant, swear we will next time, then don’t

  • ik5pvx@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    8 months ago

    Is there a particular reason you can’t just open 2 xterm and run each command in its own ?

  • just_another_person@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    8 months ago

    Shouldn’t your LLM be solving this problem.for you? 😂

    Seriously though, if not two terms, then just background one or both of these commands.

    • j4k3@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      8 months ago

      Indeed that works in the terminal to launch both my function and the application.

      How would I do this inside a single function, like launch, then drop into the loop?

      • mozz@mbin.grits.dev
        link
        fedilink
        arrow-up
        0
        ·
        8 months ago

        I’m having trouble understanding the question.

        while true; do update-header-bar-or-whatever; sleep 5; done &
        oogabooga
        

        … will run the header update every 5 seconds, while oogabooga is running. Is that what you want?

        • j4k3@lemmy.worldOP
          link
          fedilink
          English
          arrow-up
          0
          ·
          8 months ago

          If I launch like that it would stop at the oobabooga app launch until the job completed then it would resume the loop.

          Ultimately, I’m doing more complex stuff and simplifying the question so it may seem slightly overkill to say I need it to work like this. I want to do some container checks, setup, and launch multiple applications with my own parsing flags and some conditional sourcing.

          This only part I can’t seem to grasp very well is how to run that little loop and update the header while other stuff launches with its serial terminal set to the same one the loop is running inside.

          • mozz@mbin.grits.dev
            link
            fedilink
            arrow-up
            0
            ·
            8 months ago
            $ while true; do echo Hello, I updated the header; sleep 5; done &
            [1] 1631507
            $ Hello, I updated the header
            sleep 30; echo Sleep is done.
            Hello, I updated the header
            Hello, I updated the header
            Hello, I updated the header
            Hello, I updated the header
            Hello, I updated the header
            Hello, I updated the header
            Hello, I updated the header
            Sleep is done.
            Hello, I updated the header
            $ kill %1
            [1]+  Terminated              while true; do
                echo Hello, I updated the header; sleep 5;
            done
            $
            

            Edit: I’m fairly confident now that you’re just thinking the loop will stop when you run oogabooga, but that’s not how it works. That up above is how it works; the loop keeps going during the sleep with them both going on the same terminal, then after the sleep process terminates, I kill the loop, but for the whole 30 seconds previous, they were both going. It’ll be the same with oogabooga. This the situation you’re asking about, yes?

  • experbia@lemmy.world
    link
    fedilink
    arrow-up
    0
    ·
    8 months ago

    as already mentioned, ampersand allows you to “background” a task. but if you’d like the output from your program alongside the loop monitoring system info, consider using a terminal multiplexer like tmux.

    on the terminal, this will let you open a “split screen” pane with another shell. you can use hotkeys to create, destroy, or move between views.

    • j4k3@lemmy.worldOP
      link
      fedilink
      English
      arrow-up
      0
      ·
      8 months ago

      Already using Terminator and just separate terminals with a bunch of unnecessary extras to create a colorful monitoring output that changes colors as I run out of available memory. In truth I just need the number and temperature. I hate the giant Gnome headers, so I might as well put something useful in one. I don’t use the gnome terminal because it can’t split windows and always hogs my space with that obtuse header. I’m trying to make everything simply run from a single command in a single terminal.

      I don’t want to run additional complex tools, especially anything ancient that expects users to memorize unique hotkey commands. My brain is just too small for everyone’s hotkeys and the other things I’m interested in spending time on in life.

      Worst case I can nest my functions another layer deep. I think there should be a way to do this inside a single function.