Git Product home page Git Product logo

Comments (1)

gjcarneiro avatar gjcarneiro commented on August 21, 2024

Your problem is essentially a common pitfall of shell scripts. The documentation says:

The command can be a string or a list of strings. If command is a string, yacron runs it through a shell, which is /bin/bash in the above example, but is /bin/sh by default.

If the command is a list of strings, the command is executed directly, without a shell.

The configuration

command: |
      sleep 999

causes yacron to execute /bin/sh -c "sleep 999". That creates a tree of two processes:

  1. /bin/sh (parent)
  2. sleep 999 (child)
    Then, when yacron tries to terminate the process, after timeout, it sends a signal to the parent process, /bin/sh, which correctly terminates, but leaves child sleep 999 running, orphaned.

There are multiple ways to fix this issue.

Option 1: put an exec.

command: |
      exec sleep 999

In this case, yacron runs /bin/sh -c "exec sleep 999". But the exec keyword causes the sleep command to replace the parent process, taking its place, so you no longer have parent and child, only parent.

Option 2: tell yacron not to run a shell at all, giving it a list of strings as command:

    command:
      - sleep
      - "999"

This causes yacron to run /usr/bin/sleep 999 directly, no shell involved.

Option 3: modify the shell code to run to handle SIGTERM:

    command: |
      sleep 999 &
      mysleep=$!
      trap "kill $mysleep" TERM
      wait $mysleep

from yacron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.