-
Notifications
You must be signed in to change notification settings - Fork 311
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
scripts: support minos 2.0 #298
Merged
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/bin/bash | ||
|
||
# | ||
# You should set these environment variables: | ||
# * MINOS_CONFIG_FILE | ||
# * MINOS_CLIENT_DIR | ||
# * MINOS2_CONFIG_FILE | ||
# * MINOS2_CLIENT_DIR | ||
# | ||
# For example: | ||
# export MINOS_CONFIG_FILE=$HOME/infra/deployment-config/deploy.cfg | ||
# export MINOS_CLIENT_DIR=$HOME/infra/minos/client | ||
# export MINOS2_CONFIG_FILE=$HOME/infra/deployment/deploy.cfg | ||
# export MINOS2_CLIENT_DIR=$HOME/infra/minos2/client | ||
# | ||
|
||
# usage: find_cluster <cluster_name> | ||
# | ||
# return 0 if found | ||
# | ||
# if found, then these global variables will be set: | ||
# * minos_type | ||
# * minos_config | ||
# * minos_client_dir | ||
function find_cluster() | ||
{ | ||
if [ -n "$MINOS_CONFIG_FILE" -a -n "$MINOS_CLIENT_DIR" ]; then | ||
minos_type=1 | ||
minos_config=$(dirname $MINOS_CONFIG_FILE)/xiaomi-config/conf/pegasus/pegasus-${1}.cfg | ||
minos_client_dir=$MINOS_CLIENT_DIR | ||
if [ -f "$minos_config" -a -f "$minos_client_dir/deploy" ]; then | ||
return 0 | ||
fi | ||
fi | ||
|
||
if [ -n "$MINOS2_CONFIG_FILE" -a -n "$MINOS2_CLIENT_DIR" ]; then | ||
minos_type=2 | ||
minos_config=$(dirname $MINOS2_CONFIG_FILE)/xiaomi-config/conf/pegasus/pegasus-${1}.yaml | ||
minos_client_dir=$MINOS2_CLIENT_DIR | ||
if [ -f "$minos_config" -a -f "$minos_client_dir/deploy" ]; then | ||
return 0 | ||
fi | ||
fi | ||
|
||
return 1 | ||
} | ||
|
||
# usage: minos_show_replica <cluster_name> <result_file> | ||
function minos_show_replica() | ||
{ | ||
local pwd=`pwd` | ||
local tmp_file="/tmp/$UID.$PID.pegasus.minos.show" | ||
cd $minos_client_dir | ||
./deploy show pegasus $1 --job replica &>$tmp_file | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: minos show replica failed, refer to $tmp_file" | ||
exit 1 | ||
fi | ||
if [ $minos_type -eq 1 ]; then | ||
grep -o 'Showing task [0-9][0-9]* of replica on [^(]*' $tmp_file | awk '{print $3,$7}' >$2 | ||
else | ||
grep -o 'Task [0-9][0-9]* of replica on [^:]*' $tmp_file | awk '{print $2,$6}' >$2 | ||
fi | ||
cd $pwd | ||
} | ||
|
||
# usage: minos_rolling_update <cluster_name> <job_name> [task_id] | ||
function minos_rolling_update() | ||
{ | ||
local pwd=`pwd` | ||
local options="--job $2" | ||
if [ -n "$3" ]; then | ||
options="$options --task $3" | ||
fi | ||
options="$options --update_package --update_config --time_interval 20 --skip_confirm" | ||
if [ $minos_type -eq 2 ]; then | ||
options="$options --confirm_install" | ||
fi | ||
cd $minos_client_dir | ||
echo "./deploy rolling_update pegasus $1 $options" | ||
./deploy rolling_update pegasus $1 $options | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: minos rolling update failed" | ||
exit 1 | ||
fi | ||
cd $pwd | ||
} | ||
|
||
# usage: minos_stop <cluster_name> <job_name> [task_id] | ||
function minos_stop() | ||
{ | ||
local pwd=`pwd` | ||
local options="--job $2" | ||
if [ -n "$3" ]; then | ||
options="$options --task $3" | ||
fi | ||
options="$options --skip_confirm" | ||
cd $minos_client_dir | ||
echo "./deploy stop pegasus $1 $options" | ||
./deploy stop pegasus $1 $options | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: minos stop failed" | ||
exit 1 | ||
fi | ||
cd $pwd | ||
} | ||
|
||
# usage: minos_restart <cluster_name> <job_name> [task_id] | ||
function minos_restart() | ||
{ | ||
local pwd=`pwd` | ||
local options="--job $2" | ||
if [ -n "$3" ]; then | ||
options="$options --task $3" | ||
fi | ||
options="$options --skip_confirm" | ||
cd $minos_client_dir | ||
echo "./deploy restart pegasus $1 $options" | ||
./deploy restart pegasus $1 $options | ||
if [ $? -ne 0 ]; then | ||
echo "ERROR: minos restart failed" | ||
exit 1 | ||
fi | ||
cd $pwd | ||
} |
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
Oops, something went wrong.
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.
minos 2.0 也可以直接stop?
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.
可以的,我试过