chore: add scripts and set tools

This commit is contained in:
Frank.R.Wu 2021-10-29 17:47:48 +08:00
parent 6ac402a47e
commit 877dcfe661
8 changed files with 85 additions and 16 deletions

2
.gitignore vendored
View File

@ -10,6 +10,6 @@
/manager.key
/WebContent/
/runnable
cmconfig.json*
/cmconfig.json*
/build/
*/build/*

0
WebContent/.keep Normal file
View File

View File

@ -36,9 +36,11 @@ dependencies {
implementation 'io.prometheus:simpleclient_httpserver:0.12.0'
testImplementation 'junit:junit:4.13.2'
}
compileJava {
options.compilerArgs<<"-Xlint:unchecked"
options.compilerArgs << "-Xlint:unchecked"
}
jar {
String libs = ''
configurations.runtimeClasspath.each {
@ -54,8 +56,18 @@ jar {
tasks.processResources.setDuplicatesStrategy(DuplicatesStrategy.INCLUDE)
task prepareWebContent(type: Exec) {
if (System.properties['os.name'].toString().toLowerCase().contains('windows')) {
commandLine "rmdir", ".\\WebContent\\ide"
commandLine "mklink", "/j", "..\\..\\agent-frontend", ".\\WebContent\\ide"
} else {
commandLine "rm", "./WebContent/ide"
commandLine "ln", "-s", "../../agent-frontend", "./WebContent/ide"
}
}
task copyScript(type: Copy) {
from("../script/") {
from("./script/") {
include 'cmstart.sh'
include 'cmstop.sh'
include 'cmconfig.json.template'
@ -142,7 +154,7 @@ task copyKeys(type: Copy) {
into "./build/output/keys"
}
task buildBDServerZip(type: Zip, dependsOn: [ ":agent-backend:copyWebContent",
task buildBDServerZip(type: Zip, dependsOn: [":agent-backend:copyWebContent",
":agent-backend:copyBDWareProjectDir", ":agent-backend:copyScript",
":agent-backend:copyJar", ":agent-backend:copyLibs", ":agent-backend:copyKeys"]) {
from './build/output/'
@ -151,7 +163,7 @@ task buildBDServerZip(type: Zip, dependsOn: [ ":agent-backend:copyWebContent",
destinationDirectory = file('build/')
}
task buildBDServerZipLite(type: Zip, dependsOn: [ ":agent-backend:copyWebContent",
task buildBDServerZipLite(type: Zip, dependsOn: [":agent-backend:copyWebContent",
":agent-backend:copyBDWareProjectDir", ":agent-backend:copyScript",
":agent-backend:copyJar", ":agent-backend:copyLibs", ":agent-backend:copyKeys"]) {
from('./build/output/') {

View File

@ -0,0 +1,15 @@
{
"ip": "127.0.0.1",
"servicePort": 21030,
"isLAN" : true,
"disableDoRepo": false,
"doipPort": 21032,
"doipCertPath": "",
"doipUserHandle": "",
"doipLhsAddress": "",
"withBdledgerServer": false,
"withBdledgerClient": "",
"enableEventPersistence": false,
"enableSsl": "./ssl/chained.pem:./ssl/domain.pem",
"textFileSuffixes": ".yjs,.json,.txt,.css,.js,.html,.md,.conf,.csv"
}

26
script/cmstart.sh Executable file
View File

@ -0,0 +1,26 @@
#!/bin/bash
if [ ! -d "log/" ]; then
mkdir "log"
fi
bash ./cmstop.sh
time=$(date "+%Y_%m_%d_%H:%M:%S")
if [ -f "./log/cm.log" ]; then
echo "move log ./log/cm_${time}.log"
mv ./log/cm.log "./log/cm_${time}.log"
fi
if [ -f "./log/cm.err" ]; then
mv ./log/cm.err "./log/cm_${time}.err"
fi
# ps -ef | grep java | grep bdserver | grep CM | awk '{print $2}' | xargs kill -9
java -Dfile.encoding=UTF-8 -Djava.library.path="./dynamicLibrary" -cp "./libs/*:bdagent.jar" org.bdware.server.CMHttpServer 1>./log/cm.log 2>./log/cm.err &
#-Xmx3550m -Xms3550m -Xmn2g
#-XX:+UseConcMarkSweepGC -XX:CMSFullGCsBeforeCompaction=5
# 以下可启用https/wss其中./ssl/xxx.pfx为ssl证书的路径:后面的123456是密码。
# java -Dfile.encoding=UTF-8 -cp "./libs/*:bdagent.jar" org.bdware.server.CMHttpServer -service-port=8080 -enable-ssl=./ssl/xxx.pfx:123456 -do-repo-ip=127.0.0.1 -do-repo-port=18099 1 > ./log/cm.log 2> ./log/cm.err &
echo $! >./PID

10
script/cmstop.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
if [ -a "./PID" ]; then
ls /proc/$(cat PID)/cmdline
if [ $? -eq 0 ]; then
kill -9 $(cat PID)
echo "shutdown old contract manager"
fi
rm ./PID
fi

9
script/killContracts.sh Normal file
View File

@ -0,0 +1,9 @@
#!/bin/bash
if [ -a './CMI' ]; then
ps -ef | grep java | grep yjs | grep $(cat CMI) | awk '{print $2}' | xargs kill -9
fi
if [ $# -gt 0 ]; then
echo $1
ps -ef | grep java | grep yjs | grep $1 | awk '{print $2}' | xargs kill -9
fi

View File

@ -73,7 +73,8 @@ public class CMHttpHandler extends SimpleChannelInboundHandler<HttpObject> {
new HttpFileAction(),
new BDIndexerAction(),
LedgerActions.instance,
new CMLogAction(), new TemporyTestAction()) {
new CMLogAction(),
new TemporyTestAction()) {
@Override
public boolean checkPermission(Action a, JsonObject arg, long per) {
boolean flag = a.httpAccess();
@ -103,16 +104,12 @@ public class CMHttpHandler extends SimpleChannelInboundHandler<HttpObject> {
}
TimeDBUtil.instance.put(
CMTables.LocalNodeLogDB.toString(),
"{\"action\":\""
+ action
+ "\",\"pubKey\":\""
+ pubkey
+ "\",\"status\":\""
+ status
+ "\",\"date\":"
+ System.currentTimeMillis()
+ "}");
String.format(
"{\"action\":\"%s\",\"pubKey\":\"%s\",\"status\":\"%s\",\"date\":%d}",
action,
pubkey,
status,
System.currentTimeMillis()));
return flag && flag2;
}
};