From 5dff94d9bd04bc008a416f052ccc8e55eab05ef6 Mon Sep 17 00:00:00 2001 From: "Signed-off-by: wmqwxb" <13628607970@163.com> Date: Thu, 28 Dec 2023 18:00:34 +0800 Subject: [PATCH 1/3] update component yaml Signed-off-by: wmqwxb <13628607970@163.com> --- static/coordinated_linr.yaml | 2 +- static/coordinated_lr.yaml | 2 +- static/data_split.yaml | 2 +- static/dataframe_transformer.yaml | 81 +++++++++++++--------------- static/evaluation.yaml | 7 ++- static/feature_correlation.yaml | 2 +- static/feature_scale.yaml | 2 +- static/hetero_feature_binning.yaml | 2 +- static/hetero_feature_selection.yaml | 2 +- static/hetero_nn.yaml | 6 ++- static/hetero_sbt.yaml | 49 ++++++++--------- static/hetero_secureboost.yaml | 49 ++++++++--------- static/homo_lr.yaml | 27 ++++++---- static/homo_nn.yaml | 8 +-- static/psi.yaml | 4 +- static/reader.yaml | 2 +- static/sample.yaml | 2 +- static/sshe_linr.yaml | 9 ++-- static/sshe_lr.yaml | 9 ++-- static/statistics.yaml | 2 +- static/union.yaml | 2 +- 21 files changed, 138 insertions(+), 133 deletions(-) diff --git a/static/coordinated_linr.yaml b/static/coordinated_linr.yaml index c380b8b3..0df76fdc 100644 --- a/static/coordinated_linr.yaml +++ b/static/coordinated_linr.yaml @@ -2,7 +2,7 @@ component: name: coordinated_linr description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/coordinated_lr.yaml b/static/coordinated_lr.yaml index 0c61cb1e..567449cb 100644 --- a/static/coordinated_lr.yaml +++ b/static/coordinated_lr.yaml @@ -2,7 +2,7 @@ component: name: coordinated_lr description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/data_split.yaml b/static/data_split.yaml index e3cb85ce..5509592b 100644 --- a/static/data_split.yaml +++ b/static/data_split.yaml @@ -2,7 +2,7 @@ component: name: data_split description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/dataframe_transformer.yaml b/static/dataframe_transformer.yaml index 64452ebe..e26ee884 100644 --- a/static/dataframe_transformer.yaml +++ b/static/dataframe_transformer.yaml @@ -2,67 +2,43 @@ component: name: dataframe_transformer description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - local + - guest + - host parameters: namespace: - type: parameter_namespace + type: str default: optional: true description: '' type_meta: - title: parameter_namespace - type: object - properties: - data: - title: Data - type: string - required: - - data + title: str + type: string + default: + description: '' name: - type: parameter_name + type: str default: optional: true description: '' type_meta: - title: parameter_name - type: object - properties: - data: - title: Data - type: string - required: - - data - anonymous_role: - type: parameter_anonymous_role - default: - optional: true - description: '' - type_meta: - title: parameter_anonymous_role - type: object - properties: - data: - title: Data - type: string - required: - - data - anonymous_party_id: - type: parameter_anonymous_party_id + title: str + type: string + default: + description: '' + site_name: + type: str default: optional: true description: '' type_meta: - title: parameter_anonymous_party_id - type: object - properties: - data: - title: Data - type: string - required: - - data + title: str + type: string + default: + description: '' input_artifacts: data: table: @@ -73,6 +49,8 @@ component: - default roles: - local + - guest + - host description: '' is_multi: false model: {} @@ -86,8 +64,23 @@ component: - default roles: - local + - guest + - host description: '' is_multi: false model: {} - metric: {} + metric: + metric: + types: + - json_metric + optional: false + stages: + - default + roles: + - local + - guest + - host + description: metric, invisible for user + is_multi: false schema_version: v1 + diff --git a/static/evaluation.yaml b/static/evaluation.yaml index a98f7fe0..740bbb22 100644 --- a/static/evaluation.yaml +++ b/static/evaluation.yaml @@ -2,7 +2,7 @@ component: name: evaluation description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest @@ -32,8 +32,8 @@ component: default: optional: true description: predict data column name, if None(default), will use 'predict_score' - when use binary and regression default setting, and - use 'predict_result' on multi classification default setting + in the input dataframe when the default setting are binary and regression, and + use 'predict_result' if default setting is multi type_meta: title: str type: string @@ -82,4 +82,3 @@ component: description: metric, invisible for user is_multi: false schema_version: v1 - diff --git a/static/feature_correlation.yaml b/static/feature_correlation.yaml index bf8fea87..13dd6870 100644 --- a/static/feature_correlation.yaml +++ b/static/feature_correlation.yaml @@ -2,7 +2,7 @@ component: name: feature_correlation description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/feature_scale.yaml b/static/feature_scale.yaml index cb104fe6..4a8ef5a4 100644 --- a/static/feature_scale.yaml +++ b/static/feature_scale.yaml @@ -2,7 +2,7 @@ component: name: feature_scale description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest diff --git a/static/hetero_feature_binning.yaml b/static/hetero_feature_binning.yaml index 1cd9a5d8..bc7fb81a 100644 --- a/static/hetero_feature_binning.yaml +++ b/static/hetero_feature_binning.yaml @@ -2,7 +2,7 @@ component: name: hetero_feature_binning description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/hetero_feature_selection.yaml b/static/hetero_feature_selection.yaml index f37f2f01..42d01819 100644 --- a/static/hetero_feature_selection.yaml +++ b/static/hetero_feature_selection.yaml @@ -2,7 +2,7 @@ component: name: hetero_feature_selection description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/hetero_nn.yaml b/static/hetero_nn.yaml index 51c225b9..634baa23 100644 --- a/static/hetero_nn.yaml +++ b/static/hetero_nn.yaml @@ -2,7 +2,7 @@ component: name: hetero_nn description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest @@ -53,6 +53,7 @@ component: train_data: types: - dataframe + - data_directory optional: false stages: - train @@ -64,6 +65,7 @@ component: validate_data: types: - dataframe + - data_directory optional: true stages: - train @@ -75,6 +77,7 @@ component: test_data: types: - dataframe + - data_directory optional: false stages: - predict @@ -152,4 +155,3 @@ component: description: metric, invisible for user is_multi: false schema_version: v1 - diff --git a/static/hetero_sbt.yaml b/static/hetero_sbt.yaml index 4d644ce0..c371a8e8 100644 --- a/static/hetero_sbt.yaml +++ b/static/hetero_sbt.yaml @@ -2,7 +2,7 @@ component: name: hetero_secureboost description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest @@ -76,7 +76,7 @@ component: type: bool default: false optional: true - description: whether to use goss sampling + description: whether to use goss subsample type_meta: title: bool type: boolean @@ -84,13 +84,33 @@ component: description: whether output prediction result per cv fold goss_start_iter: type: ConstrainedNumberMeta - default: 0 + default: 5 optional: true - description: start iteration of goss sampling + description: start iteration of goss subsample type_meta: title: ConstrainedNumberMeta - exclusiveMinimum: 0 + minimum: 0 type: integer + top_rate: + type: ConstrainedNumberMeta + default: 0.2 + optional: true + description: top rate of goss subsample + type_meta: + title: ConstrainedNumberMeta + exclusiveMinimum: 0 + exclusiveMaximum: 1 + type: number + other_rate: + type: ConstrainedNumberMeta + default: 0.1 + optional: true + description: other rate of goss subsample + type_meta: + title: ConstrainedNumberMeta + exclusiveMinimum: 0 + exclusiveMaximum: 1 + type: number l1: type: ConstrainedNumberMeta default: 0 @@ -205,24 +225,6 @@ component: key_length: 1024 description: homomorphic encryption param, support paillier, ou and mock in current version - top_rate: - type: ConstrainedNumberMeta - default: 0.2 - optional: true - description: top rate of goss sampling - type_meta: - title: ConstrainedNumberMeta - exclusiveMinimum: 0 - type: number - other_rate: - type: ConstrainedNumberMeta - default: 0.1 - optional: true - description: other rate of goss sampling - type_meta: - title: ConstrainedNumberMeta - exclusiveMinimum: 0 - type: number cv_param: type: CVParam default: @@ -393,4 +395,3 @@ component: description: metric, invisible for user is_multi: false schema_version: v1 - diff --git a/static/hetero_secureboost.yaml b/static/hetero_secureboost.yaml index 4d644ce0..c371a8e8 100644 --- a/static/hetero_secureboost.yaml +++ b/static/hetero_secureboost.yaml @@ -2,7 +2,7 @@ component: name: hetero_secureboost description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest @@ -76,7 +76,7 @@ component: type: bool default: false optional: true - description: whether to use goss sampling + description: whether to use goss subsample type_meta: title: bool type: boolean @@ -84,13 +84,33 @@ component: description: whether output prediction result per cv fold goss_start_iter: type: ConstrainedNumberMeta - default: 0 + default: 5 optional: true - description: start iteration of goss sampling + description: start iteration of goss subsample type_meta: title: ConstrainedNumberMeta - exclusiveMinimum: 0 + minimum: 0 type: integer + top_rate: + type: ConstrainedNumberMeta + default: 0.2 + optional: true + description: top rate of goss subsample + type_meta: + title: ConstrainedNumberMeta + exclusiveMinimum: 0 + exclusiveMaximum: 1 + type: number + other_rate: + type: ConstrainedNumberMeta + default: 0.1 + optional: true + description: other rate of goss subsample + type_meta: + title: ConstrainedNumberMeta + exclusiveMinimum: 0 + exclusiveMaximum: 1 + type: number l1: type: ConstrainedNumberMeta default: 0 @@ -205,24 +225,6 @@ component: key_length: 1024 description: homomorphic encryption param, support paillier, ou and mock in current version - top_rate: - type: ConstrainedNumberMeta - default: 0.2 - optional: true - description: top rate of goss sampling - type_meta: - title: ConstrainedNumberMeta - exclusiveMinimum: 0 - type: number - other_rate: - type: ConstrainedNumberMeta - default: 0.1 - optional: true - description: other rate of goss sampling - type_meta: - title: ConstrainedNumberMeta - exclusiveMinimum: 0 - type: number cv_param: type: CVParam default: @@ -393,4 +395,3 @@ component: description: metric, invisible for user is_multi: false schema_version: v1 - diff --git a/static/homo_lr.yaml b/static/homo_lr.yaml index ef99bb1a..88409352 100644 --- a/static/homo_lr.yaml +++ b/static/homo_lr.yaml @@ -2,7 +2,7 @@ component: name: homo_lr description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest @@ -12,9 +12,9 @@ component: learning_rate_scheduler: type: LRSchedulerParam default: - method: linear + method: constant scheduler_params: - start_factor: 1.0 + factor: 1.0 optional: true description: learning rate scheduler, select method from {'step', 'linear', 'constant'}for list of configurable arguments, refer to torch.optim.lr_scheduler @@ -34,9 +34,9 @@ component: title: Scheduler Params type: object default: - method: linear + method: constant scheduler_params: - start_factor: 1.0 + factor: 1.0 description: learning rate scheduler, select method from {'step', 'linear', 'constant'}for list of configurable arguments, refer to torch.optim.lr_scheduler epochs: @@ -52,10 +52,10 @@ component: type: ConstrainedNumberMeta default: 100 optional: true - description: batch size, value less or equals to 0 means full batch + description: batch size, int > 0, if None means full batchnon type_meta: title: ConstrainedNumberMeta - minimum: -1 + minimum: 0 type: integer optimizer: type: OptimizerParam @@ -104,9 +104,10 @@ component: init_param: type: InitParam default: - method: zeros + method: random fill_val: 0.0 fit_intercept: true + random_state: optional: true description: Model param init setting. type_meta: @@ -131,10 +132,14 @@ component: title: Fit Intercept default: true type: boolean + random_state: + title: Random State + type: integer default: - method: zeros + method: random fill_val: 0.0 fit_intercept: true + random_state: description: Model param init setting. threshold: type: ConstrainedNumberMeta @@ -150,12 +155,12 @@ component: type: bool default: false optional: true - description: predict threshold for binary data + description: enable ovr for multi-classifcation type_meta: title: bool type: boolean default: false - description: predict threshold for binary data + description: enable ovr for multi-classifcation label_num: type: ConstrainedNumberMeta default: diff --git a/static/homo_nn.yaml b/static/homo_nn.yaml index 8ecc8ce1..d68745fb 100644 --- a/static/homo_nn.yaml +++ b/static/homo_nn.yaml @@ -2,7 +2,7 @@ component: name: homo_nn description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest @@ -11,7 +11,7 @@ component: parameters: runner_module: type: str - default: default_runner + default: homo_default_runner optional: true description: name of your runner script type_meta: @@ -54,6 +54,7 @@ component: train_data: types: - dataframe + - data_directory optional: false stages: - train @@ -65,6 +66,7 @@ component: validate_data: types: - dataframe + - data_directory optional: true stages: - train @@ -76,6 +78,7 @@ component: test_data: types: - dataframe + - data_directory optional: false stages: - predict @@ -153,4 +156,3 @@ component: description: metric, invisible for user is_multi: false schema_version: v1 - diff --git a/static/psi.yaml b/static/psi.yaml index 7f93b1b8..a0a9c701 100644 --- a/static/psi.yaml +++ b/static/psi.yaml @@ -2,7 +2,7 @@ component: name: psi description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest @@ -68,4 +68,4 @@ component: - host description: metric, invisible for user is_multi: false -schema_version: v1 \ No newline at end of file +schema_version: v1 diff --git a/static/reader.yaml b/static/reader.yaml index 0efcd3a0..101c031c 100644 --- a/static/reader.yaml +++ b/static/reader.yaml @@ -2,7 +2,7 @@ component: name: reader description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [] roles: - guest diff --git a/static/sample.yaml b/static/sample.yaml index 42489214..5ee27431 100644 --- a/static/sample.yaml +++ b/static/sample.yaml @@ -2,7 +2,7 @@ component: name: sample description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/sshe_linr.yaml b/static/sshe_linr.yaml index 95da33a1..bcdfba9d 100644 --- a/static/sshe_linr.yaml +++ b/static/sshe_linr.yaml @@ -2,7 +2,7 @@ component: name: sshe_linr description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest @@ -40,7 +40,8 @@ component: type: type default: diff optional: true - description: early stopping criterion, choose from {weight_diff, diff, abs} + description: early stopping criterion, choose from {weight_diff, diff, abs}, + if use weight_diff,weight will be revealed every epoch type_meta: title: type type: string @@ -57,8 +58,8 @@ component: type: bool default: false optional: true - description: whether reveal encrypted result every epoch, if False, only reveal - at the end of training + description: whether reveal encrypted result every epoch, only accept False + for now type_meta: title: bool type: boolean diff --git a/static/sshe_lr.yaml b/static/sshe_lr.yaml index df0b8cdd..8aa25fce 100644 --- a/static/sshe_lr.yaml +++ b/static/sshe_lr.yaml @@ -2,7 +2,7 @@ component: name: sshe_lr description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest @@ -40,7 +40,8 @@ component: type: type default: diff optional: true - description: early stopping criterion, choose from {weight_diff, diff, abs} + description: early stopping criterion, choose from {weight_diff, diff, abs}, + if use weight_diff,weight will be revealed every epoch type_meta: title: type type: string @@ -57,8 +58,8 @@ component: type: bool default: false optional: true - description: whether reveal encrypted result every epoch, if False, only reveal - at the end of training + description: whether reveal encrypted result every epoch, only accept False + for now type_meta: title: bool type: boolean diff --git a/static/statistics.yaml b/static/statistics.yaml index 955643f4..8d7fafc0 100644 --- a/static/statistics.yaml +++ b/static/statistics.yaml @@ -2,7 +2,7 @@ component: name: statistics description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest diff --git a/static/union.yaml b/static/union.yaml index 3a5d340a..f1ff1d42 100644 --- a/static/union.yaml +++ b/static/union.yaml @@ -2,7 +2,7 @@ component: name: union description: '' provider: fate - version: 2.0.0-beta + version: 2.0.0 labels: [ ] roles: - guest From 1fca48348bd51e6ad37527dadb72664e51c3b565 Mon Sep 17 00:00:00 2001 From: "Signed-off-by: wmqwxb" <13628607970@163.com> Date: Thu, 28 Dec 2023 21:05:13 +0800 Subject: [PATCH 2/3] change start shell Signed-off-by: wmqwxb <13628607970@163.com> --- bin/service.sh | 334 ++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 260 insertions(+), 74 deletions(-) diff --git a/bin/service.sh b/bin/service.sh index 597e5208..a528b4e8 100644 --- a/bin/service.sh +++ b/bin/service.sh @@ -15,6 +15,45 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# --------------- Color Definitions --------------- +esc_c="\033[0m" +error_c="\033[31m" +ok_c="\033[32m" +#highlight_c="\033[43m" + +# --------------- Logging Functions --------------- +print_info() { + local timestamp=$(date '+%Y-%m-%d %H:%M:%S') + local overwrite=$2 + + # Check if we need to overwrite the current line + if [ "$overwrite" == "overwrite" ]; then + echo -ne "\r${ok_c}[${timestamp}][INFO]${esc_c} $1" + else + echo -e "${ok_c}[${timestamp}][INFO]${esc_c} $1" + fi +} +print_ok() { + local overwrite=$2 + local timestamp=$(date '+%Y-%m-%d %H:%M:%S') + if [ "$overwrite" == "overwrite" ]; then + echo -ne "\r${ok_c}[${timestamp}][ OK ]${esc_c} $1" + else + echo -e "${ok_c}[${timestamp}][ OK ]${esc_c} $1" + fi +} +print_error() { + local overwrite=$3 + local timestamp=$(date '+%Y-%m-%d %H:%M:%S') + if [ "$overwrite" == "overwrite" ]; then + echo -ne "\r${error_c}[${timestamp}][ ER ]${esc_c} $1: $2" + else + echo -e "${error_c}[${timestamp}][ ER ]${esc_c} $1: $2" + fi +} + + + basepath=$( cd $(dirname $0) pwd @@ -31,116 +70,263 @@ fatepath=$( cd $basepath/.. pwd ) - cd $basepath +export BOARD_HOME=`pwd` + +print_info "BOARD_HOME=${BOARD_HOME}" + +eval action=\$$# + main_class=org.fedai.fate.board.bootstrap.Bootstrap module=fateboard version=2.0.0 - -if test -f "${fatepath}/fate_flow/bin/init_env.sh";then - source ${fatepath}/fate_flow/bin/init_env.sh - echo "JAVA_HOME=$JAVA_HOME" -else - echo "file not found:${fatepath}/fate_flow/bin/init_env.sh" - exit +if [ $action = starting ];then + action=start +elif [ $action = restarting ];then + action=restart fi - +# Get the PID of the process getpid() { pid=$(ps -ef | grep java | grep ${basepath}/fateboard-${version}.jar | grep -v grep | awk '{print $2}') + if [[ -n ${pid} ]]; then + return 0 + else + return 1 + fi +} +# Get the PID of the process using a specific port +get_port_pid() { + pid=$(lsof -i:${port} | grep 'LISTEN' | awk 'NR==1 {print $2}') if [[ -n ${pid} ]]; then - return 1 + return 0 else - return 0 + return 1 fi } +# --------------- Functions for stop--------------- +# Function to kill a process +kill_process() { + local pid=$1 + local signal=$2 + kill ${signal} "${pid}" 2>/dev/null +} + +get_property() { + property_value=`grep $1 ${BOARD_HOME}/conf/application.properties | cut -d= -f 2-` +} + + +main() { + get_property "server.port" + port=${property_value} +} + +action() { + case "$action" in + debug) + stop + sleep_time=${3:-2} + print_info "Waiting ${sleep_time} seconds" + sleep "$sleep_time" + debug + status + ;; + start) + start + status + ;; + stop) + stop + ;; + status) + status + ;; + restart) + stop + sleep_time=${3:-2} # 默认 sleep_time 为 5,如果传入了参数,则使用传入的值 + print_info "Waiting ${sleep_time} seconds" + sleep "$sleep_time" + start + status + ;; + *) + usage + exit 1 + esac +} + + +# --------------- Functions for info--------------- +# Print usage information for the script +usage() { + echo -e "${ok_c}board${esc_c}" + echo "------------------------------------" + echo -e "${ok_c}Usage:${esc_c}" + echo -e " `basename ${0}` [component] start - Start the server application." + echo -e " `basename ${0}` [component] stop - Stop the server application." + echo -e " `basename ${0}` [component] status - Check and report the status of the server application." + echo -e " `basename ${0}` [component] restart [time] - Restart the server application. Optionally, specify a sleep time (in seconds) between stop and start." + echo -e " `basename ${0}` [component] debug - Start the server application in debug mode." + echo -e " The ${ok_c}component${esc_c} include: {fate_board} " + echo "" + echo -e "${ok_c}Examples:${esc_c}" + echo " `basename ${0}` fateboard start" + echo " `basename ${0}` fateboard restart 5" + echo "" + echo -e "${ok_c}Notes:${esc_c}" + echo " - The restart command, if given an optional sleep time, will wait for the specified number of seconds between stopping and starting the service." + echo " If not provided, it defaults to 2 seconds." + echo " - Ensure that the required Java environment is correctly configured on the system." + echo "" + echo "For more detailed information, refer to the script's documentation or visit the official documentation website." +} + + + mklogsdir() { - if [[ ! -d "logs" ]]; then - mkdir logs - fi + if [[ ! -d "${BOARD_HOME}/logs" ]]; then + mkdir -p ${BOARD_HOME}/logs + fi } +# --------------- Functions for status--------------- +# Check the status of the service status() { + print_info "---------------------------------status---------------------------------" getpid - if [[ -n ${pid} ]]; then - echo "status: - $(ps aux | grep ${pid} | grep -v grep)" + # check service is up and running + if [[ -n ${pid} ]]; then + print_ok "Check service ${module} is started: PID=${pid}${esc_c}" + print_info "The service status is: + `ps aux | grep ${pid} | grep ${main_class} | grep -v grep`" return 0 - else - echo "service not running" - return 1 - fi + else + print_error "The ${module} service is not running" + return 1 + fi +} +# check java environment +check_java_environment() { + #检查是否已经设置 JAVA_HOME 环境变量 + if [ -n "$JAVA_HOME" ]; then + print_ok "JAVA_HOME is set to $JAVA_HOME" + else + print_error "JAVA_HOME is not set" + exit 1 + fi + #检查 Java 可执行文件是否在系统 PATH 中 + if command -v java &> /dev/null; then + print_ok "Java is installed and available in the system PATH" + else + print_error "Java is not found in the system PATH" + exit 1 + fi + + #检查 Java 版本 + java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}') + if [ -n "$java_version" ]; then + print_ok "Java version is $java_version" + else + print_error "Java version information is not available" + exit 1 + fi } +# Start service start() { + print_info "--------------------------------starting--------------------------------" + print_info "Checking Java environment..." + # check the java environment + check_java_environment getpid - if [[ $? -eq 0 ]]; then - mklogsdir - if [[ $1 == "front" ]]; then - exec $JAVA_HOME/bin/java -Dspring.config.location=$configpath/application.properties -Dssh_config_file=$basepath/ssh/ -Xmx2048m -Xms2048m -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -cp $libpath/*:$basepath/${module}-${version}.jar ${main_class} >/dev/null 2>&1 - else - nohup $JAVA_HOME/bin/java -Dspring.config.location=$configpath/application.properties -Dssh_config_file=$basepath/ssh/ -Xmx2048m -Xms2048m -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -cp $libpath/*:$basepath/${module}-${version}.jar ${main_class} >/dev/null 2>&1 & + if [[ $? -eq 1 ]]; then + mklogsdir + export module=${module} + cmd="$JAVA_HOME/bin/java -Dspring.config.location=$configpath/application.properties -Dssh_config_file=$basepath/ssh/ -Xmx2048m -Xms2048m -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -cp $libpath/*:$basepath/${module}-${version}.jar ${main_class}" + print_info "The command is: $cmd" + if [[ $1 == "front" ]]; then + exec $cmd >> ${BOARD_HOME}/logs/bootstrap.${module}.out 2>>${BOARD_HOME}/logs/bootstrap.${module}.err + else + exec $cmd >> ${BOARD_HOME}/logs/bootstrap.${module}.out 2>>${BOARD_HOME}/logs/bootstrap.${module}.err & fi - if [[ $? -eq 0 ]]; then - sleep 2 - getpid - echo "service start sucessfully. pid: ${pid}" + + + # wait for connect DB + print_info "Waiting for start service..." + sleep 2 + getpid + if [[ $? -eq 0 ]]; then + print_ok "The ${module} service start sucessfully. PID=${pid}" + else + print_error "The ${module} service start failed" + fi + else + print_info "The ${module} service already started. PID=${pid}" + fi +} + +debug() { + print_info "--------------------------------debugging--------------------------------" + getpid + if [[ $? -eq 1 ]]; then + mklogsdir + export module=${module} + cmd="$JAVA_HOME/bin/java -server -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=7007 -Dspring.config.location=$configpath/application.properties -Dssh_config_file=$basepath/ssh/ -Xmx2048m -Xms2048m -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log -XX:+HeapDumpOnOutOfMemoryError -cp $libpath/*:$basepath/${module}-${version}.jar ${main_class}" + print_info "The command is: $cmd" + if [[ $1 == "front" ]]; then + exec $cmd >> ${BOARD_HOME}/logs/bootstrap.${module}.out 2>>${BOARD_HOME}/logs/bootstrap.${module}.err else - echo "service start failed" + exec $cmd >> ${BOARD_HOME}/logs/bootstrap.${module}.out 2>>${BOARD_HOME}/logs/bootstrap.${module}.err & fi - else - echo "service already started. pid: ${pid}" - fi + + getpid + if [[ $? -eq 0 ]]; then + print_ok "The ${module} service debug sucessfully. PID=${pid}" + else + print_error "The ${module} service debug failed" + fi + else + print_info "The ${module} service already started. PID=${pid}" + fi } +# --------------- Functions for stop--------------- +# Stop service stop() { + print_info "--------------------------------stopping--------------------------------" getpid - if [[ -n ${pid} ]]; then - echo "killing: - $(ps aux | grep ${pid} | grep -v grep)" - kill -9 ${pid} - if [[ $? -eq 0 ]]; then - echo "killed" - else - echo "kill error" - fi - else - echo "service not running" - fi + if [[ -n ${pid} ]]; then + print_info "The system is stopping the ${module} service. PID=${pid}" + print_info "The more information: + `ps aux | grep ${pid} | grep ${main_class} | grep -v grep`" + for _ in {1..100}; do + sleep 0.1 + kill_process "${pid}" + getpid + if [ -z "${pid}" ]; then + print_ok "Stop ${port} success (SIGTERM)" + return + fi + done + kill_process "${pid}" -9 && print_ok "Stop the service ${module} success (SIGKILL)" || print_error "Stop service failed" + else + print_ok "The ${module} service is not running(NOT ACTIVE))" + fi } -case "$1" in -start) - start - status - ;; - -starting) - start front - ;; - -stop) - stop - ;; -status) - status - ;; - -restart) - stop - start - status - ;; -*) - echo "usage: $0 {start|stop|status|restart}" - exit -1 - ;; -esac +# --------------- Main--------------- +# Main case for control +main +print_info "$module:${main_class}" +print_info "Processing: ${module} ${action}" +action "$1" + From fc12ccded3112c2a23c9eeb34b805452ab3e964b Mon Sep 17 00:00:00 2001 From: wmqwxb <13628607970@163.com> Date: Thu, 28 Dec 2023 21:57:16 +0800 Subject: [PATCH 3/3] change start shell Signed-off-by: wmqwxb <13628607970@163.com> --- bin/service.sh | 10 +++++----- package.xml | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/bin/service.sh b/bin/service.sh index a528b4e8..78f018cd 100644 --- a/bin/service.sh +++ b/bin/service.sh @@ -169,11 +169,11 @@ usage() { echo -e "${ok_c}board${esc_c}" echo "------------------------------------" echo -e "${ok_c}Usage:${esc_c}" - echo -e " `basename ${0}` [component] start - Start the server application." - echo -e " `basename ${0}` [component] stop - Stop the server application." - echo -e " `basename ${0}` [component] status - Check and report the status of the server application." - echo -e " `basename ${0}` [component] restart [time] - Restart the server application. Optionally, specify a sleep time (in seconds) between stop and start." - echo -e " `basename ${0}` [component] debug - Start the server application in debug mode." + echo -e " `basename ${0}` start - Start the server application." + echo -e " `basename ${0}` stop - Stop the server application." + echo -e " `basename ${0}` status - Check and report the status of the server application." + echo -e " `basename ${0}` restart [time] - Restart the server application. Optionally, specify a sleep time (in seconds) between stop and start." + echo -e " `basename ${0}` debug - Start the server application in debug mode." echo -e " The ${ok_c}component${esc_c} include: {fate_board} " echo "" echo -e "${ok_c}Examples:${esc_c}" diff --git a/package.xml b/package.xml index d3c47f3f..ca6ed9db 100644 --- a/package.xml +++ b/package.xml @@ -68,5 +68,13 @@ + + /ssh + src/main/resources + + ssh.properties + + + \ No newline at end of file