ulib.sh 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #!/bin/bash
  2. fw_depends gcc-6
  3. fw_installed ulib && return 0
  4. ULIB_VERSION=1.4.2
  5. ULIB_ROOT=$IROOT/ULib
  6. ULIB_DOCUMENT_ROOT=$ULIB_ROOT/ULIB_DOCUMENT_ROOT
  7. # Create a run directory for ULIB
  8. [ ! -e $IROOT/ulib.installed -a -d $IROOT/ULib ] && rm -rf $IROOT/ULib*
  9. mkdir -p $ULIB_ROOT
  10. mkdir -p $ULIB_DOCUMENT_ROOT
  11. #if [ "$TRAVIS" = "true" ]; then
  12. # AVOID "fatal error: postgres_fe.h: No such file or directory"
  13. sudo apt-get install -y postgresql-server-dev-all
  14. #fi
  15. # make use of FIFO scheduling policy possible (we must avoid use of test because bash signal trapping)
  16. #type setcap >/dev/null 2>/dev/null
  17. #if [ $? -ne 0 ]; then
  18. sudo apt-get install -y libcap2-bin
  19. #fi
  20. export CC=gcc-6
  21. export CXX=g++-6
  22. export AR=gcc-ar-6
  23. export RANLIB=gcc-ranlib-6
  24. # We need to install mongo-c-driver (we don't have a ubuntu package)
  25. RETCODE=$(fw_exists ${IROOT}/mongo-c-driver.installed)
  26. if [ "$RETCODE" != 0 ]; then
  27. wget https://github.com/mongodb/mongo-c-driver/releases/download/1.1.10/mongo-c-driver-1.1.10.tar.gz
  28. tar -xzf mongo-c-driver-1.1.10.tar.gz
  29. cd mongo-c-driver-1.1.10/
  30. ./configure --prefix=$IROOT --libdir=$IROOT
  31. make && sudo make install
  32. touch ${IROOT}/mongo-c-driver.installed
  33. fi
  34. cd $IROOT
  35. if [ -e ../results/ULib-${ULIB_VERSION}.tar.gz ]; then
  36. mv ../results/ULib-${ULIB_VERSION}.tar.gz .
  37. else
  38. # 1. Download ULib
  39. fw_get -o ULib-${ULIB_VERSION}.tar.gz https://github.com/stefanocasazza/ULib/archive/v${ULIB_VERSION}.tar.gz
  40. fi
  41. fw_untar ULib-${ULIB_VERSION}.tar.gz
  42. # 2. Compile application (userver_tcp)
  43. cd ULib-$ULIB_VERSION
  44. # AVOID "configure: error: newly created file is older than distributed files! Check your system clock"
  45. find . -exec touch {} \;
  46. cp -r tests/examples/benchmark/FrameworkBenchmarks/ULib/db $ULIB_ROOT
  47. cat <<EOF >$ULIB_ROOT/benchmark.cfg
  48. userver {
  49. PORT 8080
  50. PREFORK_CHILD 2
  51. TCP_LINGER_SET 0
  52. LISTEN_BACKLOG 16384
  53. ORM_DRIVER "mysql pgsql"
  54. CLIENT_FOR_PARALLELIZATION 100
  55. DOCUMENT_ROOT $ULIB_DOCUMENT_ROOT
  56. }
  57. EOF
  58. USP_FLAGS="-DAS_cpoll_cppsp_DO" \
  59. ./configure --prefix=$ULIB_ROOT \
  60. --disable-static --disable-examples \
  61. --with-mysql --with-pgsql \
  62. --without-ssl --without-pcre --without-expat \
  63. --without-libz --without-libuuid --without-magic --without-libares \
  64. --enable-static-orm-driver='mysql pgsql' --enable-static-server-plugin=http \
  65. --with-mongodb --with-mongodb-includes="-I$IROOT/include/libbson-1.0 -I$IROOT/include/libmongoc-1.0" --with-mongodb-ldflags="-L$IROOT"
  66. # --enable-debug \
  67. #USP_LIBS="-ljson" \
  68. #cp $TROOT/src/* src/ulib/net/server/plugin/usp
  69. make install
  70. cd examples/userver
  71. make install
  72. # Never use setcap inside of TRAVIS
  73. [ "$TRAVIS" != "true" ] || { \
  74. if [ `ulimit -r` -eq 99 ]; then
  75. sudo setcap cap_sys_nice,cap_sys_resource,cap_net_bind_service,cap_net_raw+eip $IROOT/ULib/bin/userver_tcp
  76. fi
  77. }
  78. # Compile usp pages (no more REDIS)
  79. cd ../../src/ulib/net/server/plugin/usp
  80. make json.la plaintext.la db.la query.la update.la fortune.la cached_worlds.la \
  81. mdb.la mquery.la mupdate.la mfortune.la
  82. # rdb.la rquery.la rupdate.la rfortune.la
  83. # Check that compilation worked
  84. if [ ! -e .libs/cached_worlds.so ]; then
  85. exit 1
  86. fi
  87. cp .libs/json.so .libs/plaintext.so \
  88. .libs/db.so .libs/query.so .libs/update.so .libs/fortune.so .libs/cached_worlds.so \
  89. .libs/mdb.so .libs/mquery.so .libs/mupdate.so .libs/mfortune.so $ULIB_DOCUMENT_ROOT
  90. # .libs/rdb.so .libs/rquery.so .libs/rupdate.so .libs/rfortune.so \
  91. cat <<EOF >$IROOT/ulib.installed
  92. export ULIB_ROOT=${ULIB_ROOT}
  93. export ULIB_VERSION=${ULIB_VERSION}
  94. export ULIB_DOCUMENT_ROOT=${ULIB_DOCUMENT_ROOT}
  95. export PATH=${ULIB_ROOT}/bin:${PATH}
  96. EOF
  97. source $IROOT/ulib.installed