Skip to content

Commit

Permalink
Merge pull request #36 from frankfreedom/feature-script-optimization
Browse files Browse the repository at this point in the history
服务启动脚本优化
  • Loading branch information
SelfImpr001 authored Aug 30, 2020
2 parents f70e116 + a69cce2 commit 7e4251d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,19 +202,20 @@ public Map<String, ValidationReport> uploadProject(final Project project,
private File unzipProject(final File archive, final String fileType)
throws ProjectManagerException {
final File file;
try {

if (fileType == null) {
throw new ProjectManagerException("Unknown file type for "
+ archive.getName());
} else if ("zip".equals(fileType)) {
file = unzipFile(archive);
try {
file = unzipFile(archive);
} catch (final Exception e) {
throw new ProjectManagerException("Error unzipping file:" + archive.getName() + ", Please check if there are Chinese characters in the file name.", e);
}
} else {
throw new ProjectManagerException("Unsupported archive type for file "
+ archive.getName());
}
} catch (final IOException e) {
throw new ProjectManagerException("Error unzipping file.", e);
}
return file;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ private void loadProjectFromDir(final String base, final File dir, Props parent)
final FlowProps flowProps = new FlowProps(parent);
this.flowPropsList.add(flowProps);
} catch (final IOException e) {
this.errors.add("Error loading properties " + file.getName() + ":"
this.logger.error("Error loading properties {}, cause by :", file.getName(), e);
this.errors.add("Error loading properties " + file.getName() + ", cause by :"
+ e.getMessage());
}

Expand All @@ -175,7 +176,7 @@ private void loadProjectFromDir(final String base, final File dir, Props parent)
try {
if (!this.duplicateJobs.contains(jobName)) {
if (this.jobPropsMap.containsKey(jobName)) {
this.errors.add("Duplicate job names found '" + jobName + "'.");
this.errors.add("Duplicate job names found '" + file.getName() + "'.");
this.duplicateJobs.add(jobName);
this.jobPropsMap.remove(jobName);
this.nodeMap.remove(jobName);
Expand All @@ -187,7 +188,7 @@ private void loadProjectFromDir(final String base, final File dir, Props parent)
final Node node = new Node(jobName);
final String type = prop.getString("type", null);
if (type == null) {
this.errors.add("Job doesn't have type set '" + jobName + "', please check whether the file encoding is UNIX, UTF-8.");
this.errors.add("Job type property not found in file '" + file.getName() + "', please check whether the file encoding is UNIX, UTF-8.");
}

node.setType(type);
Expand All @@ -212,7 +213,8 @@ private void loadProjectFromDir(final String base, final File dir, Props parent)
}
}
} catch (final IOException e) {
this.errors.add("Error loading job file " + file.getName() + ":"
this.logger.error("Error loading job file {}, cause by :", file.getName(), e);
this.errors.add("Error loading job file " + file.getName() + ", cause by : "
+ e.getMessage());
}
}
Expand Down Expand Up @@ -286,19 +288,22 @@ private void resolveDependencies() {
if (this.duplicateJobs.contains(dependencyName)) {
edge.setError("Ambiguous Dependency. Duplicates found.");
dependencies.put(dependencyName, edge);
this.errors.add(node.getId() + " 依赖关系不清晰 "
// 依赖关系不清晰
this.errors.add(node.getId() + " has ambiguous dependency, please check the dependency information."
+ dependencyName);
} else {
edge.setError("Dependency not found.");
dependencies.put(dependencyName, edge);
this.errors.add(node.getId() + " 找不到依赖 "
// 找不到依赖
this.errors.add(node.getId() + " cannot find dependency, please check the dependency information. "
+ dependencyName);
}
} else if (dependencyNode == node) {
// We have a self cycle
edge.setError("Self cycle found.");
dependencies.put(dependencyName, edge);
this.errors.add(node.getId() + " 有一个死循环");
// 有一个死循环
this.errors.add(node.getId() + " has a self cycle, please check the dependency information.");
} else {
dependencies.put(dependencyName, edge);
}
Expand Down
29 changes: 20 additions & 9 deletions azkaban-exec-server/src/bin/internal/internal-start-executor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,15 @@ function start(){
LOG INFO "Starting AzkabanExecutorServer on port $executorport ..."
java $AZKABAN_OPTS $JAVA_LIB_PATH -cp $CLASSPATH azkaban.execapp.AzkabanExecutorServer -conf $conf $@ >> $logFile 2>&1 &
echo $! > $azkaban_dir/currentpid
LOG INFO "AzkabanExecutorServer started successfully."
sleep 3s
processName=`jps|grep AzkabanExecutorServer`
if [ ! -n "$processName" ]
then
LOG INFO "AzkabanExecutorServer startup failed"
return 1
else
return 0
fi
}

function genServerId(){
Expand Down Expand Up @@ -126,27 +134,30 @@ function updataExecutorStatus(){
runtime=0
while [[ $start_finish != 1 ]]; do
result=`curl -POST http://${LOCAL_HOSTNAME}:${EXECUTOR_PORT}/executor -d action=activate`
LOG INFO " 执行结果: ${result}"
LOG INFO " exectue result: ${result}"
[[ "${result}" =~ .*success.* ]] && { break; }
sleep 5s
sleep 3s
runtime=$(( $runtime + 1 ))
LOG INFO " 当前运行次数为${runtime} 超过30次将退出"
if [ ${runtime} -gt 30 ]
LOG INFO "It has been run${runtime} and will exit after 10 times"
if [ ${runtime} -gt 10 ]
then
LOG ERROR "update executor status time out."
return 1
fi
done
LOG INFO " 执行节点启动成功,更新数据库状态。"
LOG INFO "update executor success."
LOG INFO "AzkabanExecutorServer started successfully."
}

function preCheck(){
LOG INFO "checking AzkabanExecutorServer status..."
if [ -f $azkaban_dir/currentpid ]
processName=`jps|grep AzkabanExecutorServer`
if [ -n "$processName" ]
then
LOG INFO "AzkabanExecutorServer already started."
return 1
LOG INFO "AzkabanExecutorServer already started."
return 1
else
return 0
fi
}

Expand Down
21 changes: 16 additions & 5 deletions azkaban-web-server/src/bin/internal/internal-start-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ logFile=/appcom/logs/azkaban/webServerLog_`date +%F+%T`.out


function preCheck(){
LOG INFO "checking AzkabanWebServer process status..."
if [ -f $azkaban_dir/currentpid ]
LOG INFO "checking AzkabanWebServer status..."
processName=`jps|grep AzkabanWebServer`
if [ -n "$processName" ]
then
LOG INFO "AzkabanWebServer already started."
return 1
LOG INFO "AzkabanWebServer already started."
return 1
else
return 0
fi
}

Expand Down Expand Up @@ -99,7 +102,15 @@ function start(){
LOG INFO "starting AzkabanWebServer..."
java $AZKABAN_OPTS $JAVA_LIB_PATH -cp $CLASSPATH azkaban.webapp.AzkabanWebServer -conf $conf $cycle_stop $@ >> $logFile 2>&1 &
echo $! > $azkaban_dir/currentpid
LOG INFO "AzkabanWebServer started successfully."
sleep 3s
processName=`jps|grep AzkabanWebServer`
if [ ! -n "$processName" ]
then
LOG INFO "AzkabanWebServer startup failed"
return 1
else
return 0
fi
}

function LOG(){
Expand Down

0 comments on commit 7e4251d

Please sign in to comment.