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

Starting iVentoy sometimes returns PID=0 #89

Open
smileymattj opened this issue Jan 4, 2025 · 0 comments
Open

Starting iVentoy sometimes returns PID=0 #89

smileymattj opened this issue Jan 4, 2025 · 0 comments

Comments

@smileymattj
Copy link

smileymattj commented Jan 4, 2025

Just a minor issue, because iVentoy is just too good and fast. :)

./iventoy.sh start output:
iventoy start SUCCESS PID=0

It seems like it's trying to execute next step too fast. I think it might be exiting before /var/run/iventoy.pid is created. Maybe there can be a very short sleep added at the end of the iventoy/lib/iventoy binary executable before it returns user to the shell. Or maybe there is a better way that avoids using sleep that can verify /var/run/iventoy.pid is populated before exiting. The reason it would be beneficial to be in the executable is if user makes custom script. For example a systemd unit file that doesn't rely on iventoy.sh

I was able to resolve by adding a 10 ms sleep line to iventoy.sh script, but this might not be the best solution:

start() {
    local PID
    local RETVAL
    
    PID=$(iventoy_get_running_pid)
    if [ $PID -ne 0 ]; then
        echo "[ERROR] iventoy is already running. PID=$PID"
        exit 1
    fi

    cd $PROJ_DIR
    $PROC_ENV $PROJ_EXEC
    RETVAL=$?
    /bin/sleep 0.01

After /bin/sleep 0.01 addition to iventoy.sh:
iventoy start SUCCESS PID=505

@smileymattj smileymattj changed the title Starting iventoy sometimes returns PID=0 Starting iVentoy sometimes returns PID=0 Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant