prepare_plugins.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #!/bin/bash
  2. #
  3. # Copyright 2021-2022 EMQ Technologies Co., Ltd.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. set -e
  18. go build -o test/plugins/pub/zmq_pub test/plugins/pub/zmq_pub.go
  19. chmod +x test/plugins/pub/zmq_pub
  20. go build -o test/plugins/service/http_server test/plugins/service/server.go
  21. chmod +x test/plugins/service/http_server
  22. go build -o test/plugins/sql/create_table test/plugins/sql/create_table.go
  23. chmod +x test/plugins/sql/create_table
  24. cd test
  25. rm -rf zmq.* Zmq.so
  26. FILE=../plugins/sources/Zmq.so
  27. if [ -f "$FILE" ]; then
  28. echo "$FILE exists, not requried to build plugin."
  29. else
  30. echo "$FILE does not exist, will build the plugin."
  31. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sources/Zmq.so ../extensions/sources/zmq/zmq.go
  32. fi
  33. mv ../plugins/sources/Zmq.so .
  34. cp ../extensions/sources/zmq/zmq.yaml .
  35. cp ../extensions/sources/zmq/zmq.json .
  36. zip zmq.zip Zmq.so zmq.yaml zmq.json
  37. rm -rf zmq.yaml Zmq.so
  38. rm -rf image.* Image.so
  39. FILE=../plugins/functions/Image.so
  40. if [ -f "$FILE" ]; then
  41. echo "$FILE exists, not requried to build plugin."
  42. else
  43. echo "$FILE does not exist, will build the plugin."
  44. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/functions/Image.so ../extensions/functions/image/*.go
  45. fi
  46. mv ../plugins/functions/Image.so .
  47. cp ../extensions/functions/image/image.json .
  48. zip image.zip Image.so image.json
  49. rm -rf Image.so
  50. # build tdengine plugins
  51. FILE=../plugins/sinks/Tdengine.so
  52. if [ -f "$FILE" ]; then
  53. echo "$FILE exists, not requried to build plugin."
  54. else
  55. echo "$FILE does not exist, will build the plugin."
  56. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sinks/Tdengine.so ../extensions/sinks/tdengine/*.go
  57. fi
  58. mv ../plugins/sinks/Tdengine.so .
  59. mv ../extensions/sinks/tdengine/tdengine.json .
  60. zip tdengine.zip Tdengine.so tdengine.json
  61. rm -rf Tdengine.so
  62. # build sql plugins
  63. FILE=../plugins/sinks/Sql.so
  64. if [ -f "$FILE" ]; then
  65. echo "$FILE exists, not required to build plugin."
  66. else
  67. echo "$FILE does not exist, will build the plugin."
  68. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sinks/Sql.so ../extensions/sinks/sql/*.go
  69. fi
  70. mv ../plugins/sinks/Sql.so .
  71. cp ../extensions/sources/sql/sql.json .
  72. zip sql.zip Sql.so sql.json
  73. rm -rf Sql.so
  74. FILE=../plugins/sources/Sql.so
  75. if [ -f "$FILE" ]; then
  76. echo "$FILE exists, not required to build plugin."
  77. else
  78. echo "$FILE does not exist, will build the plugin."
  79. go build -trimpath -modfile ../extensions.mod --buildmode=plugin -o ../plugins/sources/Sql.so ../extensions/sources/sql/*.go
  80. fi
  81. mv ../plugins/sources/Sql.so .
  82. cp ../extensions/sources/sql/sql.yaml .
  83. cp ../extensions/sources/sql/sql.json .
  84. zip sqlSrc.zip Sql.so sql.yaml sql.json
  85. rm -rf Sql.so
  86. rm -rf plugins/service/web/plugins/
  87. mkdir -p plugins/service/web/plugins/
  88. mv zmq.zip plugins/service/web/plugins/
  89. mv image.zip plugins/service/web/plugins/
  90. mv tdengine.zip plugins/service/web/plugins/
  91. mv sql.zip plugins/service/web/plugins/
  92. mv sqlSrc.zip plugins/service/web/plugins/
  93. # prepare portable plugins
  94. cd ..
  95. mkdir test/temp
  96. mkdir test/temp/mirror
  97. cd sdk/go/example/mirror
  98. go build -o ../../../../test/temp/mirror/mirror .
  99. cd ../../../..
  100. cp sdk/go/example/mirror/mirror.json test/temp/mirror
  101. cp -r sdk/go/example/mirror/sources test/temp/mirror/
  102. cd test/temp/mirror
  103. zip -r ../../plugins/service/web/plugins/mirror.zip *
  104. cd ../../..
  105. cp -r sdk/python/example/pysam test/temp/pysam
  106. cp -r sdk/python/ekuiper test/temp/pysam/
  107. cd test/temp/pysam
  108. zip -r ../../plugins/service/web/plugins/pysam.zip *
  109. cd ../..
  110. rm -r temp
  111. pids=`ps aux | grep http_server | grep "./" | awk '{printf $2 " "}'`
  112. if [ "$pids" = "" ] ; then
  113. echo "No http mockup server was started"
  114. else
  115. for pid in $pids ; do
  116. echo "kill http mockup server " $pid
  117. kill -9 $pid
  118. done
  119. fi
  120. cd plugins/service/
  121. export BUILD_ID=dontKillMe
  122. echo "starting mock http server..."
  123. nohup ./http_server > http_server.out 2>&1 &