install.sh 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # install.sh
  3. # --------------------------------------------------------------------------------------------------------
  4. # toolset/run-tests.py --install server --test ULib-mysql --type all --verbose
  5. # toolset/run-tests.py --install server --test ULib-sqlite --type all --verbose
  6. # --------------------------------------------------------------------------------------------------------
  7. # TROOT - Path of this test's directory
  8. # IROOT - Path of this test's install directory ($FWROOT/installs or $FWROOT/installs/pertest/<test-name>)
  9. # --------------------------------------------------------------------------------------------------------
  10. # INFO:root:Running installation for ULib
  11. # INSTALL:
  12. # export TROOT=$FWROOT/ULib &&
  13. # export IROOT=$FWROOT/installs &&
  14. # . $FWROOT/toolset/setup/linux/bash_functions.sh &&
  15. # . $FWROOT/ULib/install.sh (cwd=$FWROOT//installs)
  16. # --------------------------------------------------------------------------------------------------------
  17. ULIB_VERSION=1.4.2
  18. ULIB_ROOT=$IROOT/ULib
  19. ULIB_DOCUMENT_ROOT=${ULIB_ROOT}/ULIB_DOCUMENT_ROOT
  20. # Check if ULib is already installed
  21. ULIB_INSTALLED_FILE="${IROOT}/ULib-${ULIB_VERSION}.installed"
  22. RETCODE=$(fw_exists ${ULIB_INSTALLED_FILE})
  23. [ ! "$RETCODE" == 0 ] || { return 0; }
  24. # Create a run directory for ULIB
  25. [ ! -e ${ULIB_INSTALLED_FILE} -a -d ${IROOT}/ULib ] && rm -rf ${IROOT}/ULib*
  26. if [ ! -d "$ULIB_ROOT" ]; then
  27. mkdir -p $ULIB_ROOT
  28. fi
  29. # AVOID "fatal error: postgres_fe.h: No such file or directory"
  30. sudo apt-get install -y postgresql-server-dev-all
  31. # Add a simple configuration file to it
  32. cd $ULIB_ROOT
  33. if [ ! -f "benchmark.cfg" ]; then
  34. cat <<EOF >benchmark.cfg
  35. userver {
  36. PORT 8080
  37. PREFORK_CHILD 4
  38. MAX_KEEP_ALIVE 1023
  39. LISTEN_BACKLOG 16384
  40. CLIENT_FOR_PARALLELIZATION 256
  41. ORM_DRIVER "mysql pgsql sqlite"
  42. DOCUMENT_ROOT $ULIB_DOCUMENT_ROOT
  43. }
  44. EOF
  45. fi
  46. # 1. Download ULib
  47. cd $IROOT
  48. fw_get -O ULib-${ULIB_VERSION}.tar.gz https://github.com/stefanocasazza/ULib/archive/v${ULIB_VERSION}.tar.gz
  49. fw_untar ULib-${ULIB_VERSION}.tar.gz
  50. # 2. Compile application (userver_tcp)
  51. cd ULib-$ULIB_VERSION
  52. # Check for the compiler support (We want at least g++ 4.8)
  53. CC=gcc # C compiler command
  54. CXX=g++ # C++ compiler command
  55. gcc_version=`g++ -dumpversion`
  56. case "$gcc_version" in
  57. 3*|4.0*|4.1*|4.2*|4.3*|4.4*|4.5*|4.6*|4.7*)
  58. CC='gcc-4.8'
  59. CXX='g++-4.8'
  60. ;;
  61. esac
  62. export CC CXX
  63. # AVOID "configure: error: newly created file is older than distributed files! Check your system clock"
  64. find . -exec touch {} \;
  65. USP_FLAGS="-DAS_cpoll_cppsp_DO" \
  66. ./configure --prefix=$ULIB_ROOT \
  67. --disable-static --disable-examples \
  68. --with-mysql --with-pgsql --with-sqlite3 \
  69. --without-ssl --without-pcre --without-expat \
  70. --without-libz --without-libuuid --without-magic --without-libares \
  71. --enable-static-orm-driver='mysql pgsql sqlite' --enable-static-server-plugin=http
  72. # --enable-debug \
  73. #USP_LIBS="-ljson" \
  74. make install
  75. cp -r tests/examples/benchmark/FrameworkBenchmarks/ULib/db ${ULIB_ROOT}
  76. cd examples/userver
  77. make install
  78. # 3. Compile usp pages for benchmark
  79. cd ../../src/ulib/net/server/plugin/usp
  80. make db.la fortune.la json.la plaintext.la query.la update.la
  81. # Check that compilation worked
  82. if [ ! -e .libs/db.so ]; then
  83. exit 1
  84. fi
  85. mkdir -p $ULIB_DOCUMENT_ROOT
  86. cp .libs/db.so .libs/fortune.so .libs/json.so .libs/plaintext.so .libs/query.so .libs/update.so $ULIB_DOCUMENT_ROOT
  87. touch ${ULIB_INSTALLED_FILE}