-
-
Notifications
You must be signed in to change notification settings - Fork 12
Kstars watchdog script added. #222
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
Open
efournie
wants to merge
2
commits into
devDucks:main
Choose a base branch
from
efournie:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| [Desktop Entry] | ||
| Comment= | ||
| Comment= | ||
| Exec=/home/astronaut/.astroarch/scripts/kstars-watchdog.sh | ||
| GenericName= | ||
| GenericName= | ||
| Icon=application-x-shellscript | ||
| MimeType= | ||
| Name=kstars-watchdog.sh | ||
| Path= | ||
| StartupNotify=true | ||
| Terminal=false | ||
| TerminalOptions= | ||
| Type=Application | ||
| X-KDE-AutostartScript=true | ||
| X-KDE-SubstituteUID=false | ||
| X-KDE-Username= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This script starts Kstars then Ekos with the default profile. | ||
| # If Kstars is already running, the script will monitor it. | ||
| # If an Ekos scheduler job file named default.esl exists in the | ||
| # home directory, the telescope is unparked and the scheduler | ||
| # job file will be loaded and started. | ||
| # If Kstars is closed or crashes, the script will restart it | ||
| # automatically. | ||
|
|
||
| SCHEDFILE=/home/astronaut/default.esl # Can be a link to a .esl file located elsewhere or a real file | ||
| LOGFILE=/dev/null | ||
| # LOGFILE=/home/astronaut/kstars.log | ||
| echo $'\n\n\n\n\n' >> $LOGFILE | ||
| date >> $LOGFILE | ||
|
|
||
| # Setup X | ||
|
|
||
| export DISPLAY=:0 | ||
| XAUTHORITY=`ls /tmp/xauth_* -tr | tail -n1` | ||
| xhost +local: >> $LOGFILE 2>&1 | ||
|
|
||
| # Main loop | ||
|
|
||
| while true | ||
| do | ||
| while true | ||
| do | ||
| if qdbus org.kde.kstars >> /dev/null 2>&1 | ||
| then | ||
| break | ||
| else | ||
| /usr/bin/kstars >> $LOGFILE 2>&1 & | ||
| fi | ||
| echo ">>> Waiting for Kstars to start..." | tee -a $LOGFILE | ||
| sleep 1 | ||
| done | ||
|
|
||
| echo ">>> Kstars started successfully." | tee -a $LOGFILE | ||
|
|
||
| CNT=1 | ||
| while true | ||
| do | ||
| qdbus org.kde.kstars /KStars/Ekos org.kde.kstars.Ekos.start >> $LOGFILE 2>&1 && break | ||
| sleep 1 | ||
| echo ">>> Waiting for ekos availability : attempt "$CNT" of 10..." | tee -a $LOGFILE | ||
| CNT=$((CNT+1)) | ||
| if (( CNT > 10 )) | ||
| then | ||
| echo ">>> Too many attempts to start ekos, aborting..." | tee -a $LOGFILE | ||
| break | ||
| fi | ||
| done | ||
| sleep 1 | ||
|
|
||
| # Show main Ekos window | ||
| qdbus org.kde.kstars /kstars/MainWindow_1/actions/show_ekos trigger | ||
|
|
||
| # At this point, INDI devices are up and running | ||
|
|
||
| # Check if the default scheduler script exists | ||
| if [ -f $SCHEDFILE ] | ||
| then | ||
| echo ">>> $SCHEDFILE found, unparking telescope and starting scheduler job." | tee -a $LOGFILE | ||
| # Unpark telescope | ||
| qdbus org.kde.kstars /kstars/MainWindow_1/actions/telescope_unpark org.qtproject.Qt.QAction.trigger | ||
|
|
||
| # (Re-)start scheduler jobs | ||
| # => load and start scheduler file | ||
| qdbus org.kde.kstars /KStars/Ekos/Scheduler loadScheduler $SCHEDFILE >> $LOGFILE 2>&1 | ||
| qdbus org.kde.kstars /KStars/Ekos/Scheduler start >> $LOGFILE 2>&1 | ||
| fi | ||
|
|
||
| # Watchdog loop, restart everything if Kstars crashes or is closed | ||
| echo ">>> Starting watchdog loop..." | tee -a $LOGFILE | ||
| while true | ||
| do | ||
| qdbus org.kde.kstars /KStars/Ekos > /dev/null 2>&1 || break | ||
| sleep 1 | ||
| done | ||
| echo ">>> Kstars has been closed or crashed, restarting in 5 seconds..." | tee -a $LOGFILE | ||
| sleep 5 | ||
| done |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@efournie there is only a small gotcha, these commands are listed here cause they are found within zshrc so users can invoke them directly in the terminal. We may need to alias that command in zshrc to invoke your bash script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am currently trying to port it to python, will probably be much more flexible and make further development easier:
https://github.com/efournie/kstars-watchdog
It's not working 100% yet but should be soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The python version seems to work now, use or adapt whichever one you prefer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you comfortable packaging python stuff? Ideally if you drop a setup.py I can package this directly for archlinux
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, sounds good! I will try to package it, never done it before but it should not be too complicated, especially with a single dependency.
I will first try to let it run one or two nights in order to check for unforeseen problems, just have to wait for a clear now!