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

Skip keymon's force shutdown if runtime is already shutting down #1579

Merged
merged 1 commit into from
May 10, 2024

Conversation

Aemiii91
Copy link
Member

@Aemiii91 Aemiii91 commented May 9, 2024

Keymon would force shutdown 30s after pressing the power button, and this would interrupt any scripts running during shutdown. This changes the keymon logic to skip the force shutdown, if the device is already in the process of shutting down.

@Aemiii91 Aemiii91 self-assigned this May 9, 2024
@Aemiii91 Aemiii91 changed the title FIX: Skip keymon's force shutdown if runtime is already shutting down Skip keymon's force shutdown if runtime is already shutting down May 9, 2024
@Aemiii91 Aemiii91 added the bug in onion Something isn't working label May 9, 2024
@Aemiii91 Aemiii91 requested a review from XK9274 May 9, 2024 21:10
Copy link
Member

@XK9274 XK9274 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with below script:

#!/bin/sh

start_time=$(date +%s)

while true; do
    current_time=$(date +%s)
    elapsed_time=$((current_time - start_time))

    echo "Script has been running for $elapsed_time seconds."

    if [ $elapsed_time -ge 85 ]; then
        echo "Script has completed its 85-second runtime."
        break
    fi

    sleep 1
done

Producing the below output:

mv: can't rename '/tmp/cmd_to_run.sh': No such file or directory
Script has been running for 0 seconds.
Script has been running for 1 seconds.
Script has been running for 3 seconds.
Script has been running for 4 seconds.
Script has been running for 5 seconds.
...
Script has been running for 81 seconds.
Script has been running for 82 seconds.
Script has been running for 83 seconds.
Script has been running for 84 seconds.
Script has been running for 85 seconds.
Script has completed its 85-second runtime.
<< Shutdown happens here
su: can't chdir to home directory '/home/root'
[1042] May 10 17:24:26 Early exit: Terminated by signal

Working as intended, thanks for your first ever contribution!

@XK9274 XK9274 added this pull request to the merge queue May 10, 2024
Merged via the queue into main with commit 046c193 May 10, 2024
2 checks passed
@XK9274 XK9274 deleted the keymon-improve-force-shutdown branch May 10, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug in onion Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants