-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[teamd]: Add teamd.sh start script to clean up STATE database #2250
Closed
Closed
Changes from all commits
Commits
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 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 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 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,61 @@ | ||
#!/bin/bash | ||
|
||
SERVICE="teamd" | ||
DEBUGLOG="/tmp/teamd-debug.log" | ||
|
||
function debug() | ||
{ | ||
/bin/echo `date` "- $1" >> ${DEBUGLOG} | ||
} | ||
|
||
function wait_for_database_service() | ||
{ | ||
# Wait for redis server start before database clean | ||
until [[ $(/usr/bin/docker exec database redis-cli ping | grep -c PONG) -gt 0 ]]; | ||
do sleep 1; | ||
done | ||
|
||
# Wait for configDB initialization | ||
until [[ $(/usr/bin/docker exec database redis-cli -n 4 GET "CONFIG_DB_INITIALIZED") ]]; | ||
do sleep 1; | ||
done | ||
} | ||
|
||
function clean_up_tables() | ||
{ | ||
redis-cli -n $1 EVAL " | ||
local tables = {$2} | ||
for i = 1, table.getn(tables) do | ||
local matches = redis.call('KEYS', tables[i]) | ||
for j,name in ipairs(matches) do | ||
redis.call('DEL', name) | ||
end | ||
end" 0 | ||
} | ||
|
||
start() { | ||
debug "Starting ${SERVICE} service..." | ||
|
||
wait_for_database_service | ||
|
||
clean_up_tables 6 "LAG_TABLE*" | ||
|
||
/usr/bin/${SERVICE}.sh start | ||
/usr/bin/${SERVICE}.sh attach | ||
} | ||
|
||
|
||
stop() { | ||
debug "Stopping ${SERVICE} service..." | ||
/usr/bin/${SERVICE}.sh stop | ||
} | ||
|
||
case "$1" in | ||
start|stop) | ||
$1 | ||
;; | ||
*) | ||
echo "Usage: $0 {start|stop}" | ||
exit 1 | ||
;; | ||
esac |
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.
why do we remove this one?
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.
In stead of removing, we can just replace existing script.
In reply to: 232916218 [](ancestors = 232916218)
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 think it's better to align all these scripts later we could have some common functions that could simplify these scripts all together
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.
Then the unused scripts should be removed.