A simple shell that collects multiple services using the Logback jar package, different services use different ports, different instances of the same service use the same port, service name and port mappings are stored in the App.list
App.list, Support # annotations
# app List
# Asset port at 570x
#asset-www 5701
#asset-api 5702
asset-m 5703
# Asset-admin 5704
# Peer port at 560x
P2p-core 5600
# MS ports at 580x
ms-www
5801 Ms-api 5802
app.sh
#!/bin/sh # auth li_jian@gozap.com # logbackserver #the app name in app.list or value ' all ' appname=$1 applistfile=app. List applen=0 Declare-a an declare-a ap if ["" = "$appname"];then cat <<eof Usage: $ [Options] Options:al L Run all app $appListFile {somename} run the specified app in $appListFile EOF fi if [!-e $appLis Tfile];then echo-e ' app list file $appListFile not exist!\n ' else while read line do if [[$line & ;& "${line:0:1}"! = "#"]];then an[$appLen]= ' echo ${line} |
awk ' {print '} '; ap[$appLen]= ' echo ${line} |
awk ' {print $} ';
#echo "${line},${an[$appLen]}" ((applen++)); Fi done < $appListFile if ["" = "$appname"];then echo-e "availble app List: \ n" echo "app Nam E: ${an[*]} All "echo" app Port: ${ap[*]} "echo" "Else Groupadd logback >/dev/null Use
Radd logback-g logback >/dev/null
Totalruns=0 for ((i=0; i<${#an [@]}; i++);d o #echo "${an[$i]}, $appname" If [["$appname" = "${an[$i]}" | | "$appname" = "All"]];then aname=${an[$i]} aport=${ap[$i]} cmd= "JAVA-CP.:./lib/* Ch. Qos.logback.classic.net.SimpleSocketServer $aport conf/logback-${aname}.xml "su logback-c" $cmd >/dev/nul
L 2>&1 & "echo" $cmd ";
((totalruns++));
Fi do echo "Total runs $totalRuns"; Fi fi
Usage:
./app.sh All
./app.sh Asset-m
Lib:
Logback-core-1.1.6.jar
Logback-classic-1.1.6.jar
Slf4j-api-1.7.12.jar
Download Address
http://download.csdn.net/detail/lanmo555/9472772
If a high-availability collection is required, it is recommended to develop failover-socket-appender or directly using LOG4J2 + Kafka + Elasticsearch + Kibana