From 60b0c4097be5cc919b17f11b3623993a279088a1 Mon Sep 17 00:00:00 2001 From: Eike Cochu <eike@cochu.com> Date: Sat, 9 Jan 2016 23:10:42 +0100 Subject: [PATCH] further fixes for new environment added project dependencies in poms pinned ui bower lib versions because of ember cli bug added mongo init file and configuration --- ma-impl.sublime-workspace | 114 +++--------- vipra-cmd/pom.xml | 7 + vipra-rest/pom.xml | 1 + vipra-ui/app/routes/articles/list.js | 2 +- vipra-ui/bower.json | 10 +- vipra-ui/package.json | 2 +- vm/bootstrap.sh | 33 +++- vm/config/initd-mongod | 267 +++++++++++++++++++++++++++ vm/config/mongod.conf | 41 ++++ 9 files changed, 377 insertions(+), 100 deletions(-) create mode 100644 vm/config/initd-mongod create mode 100644 vm/config/mongod.conf diff --git a/ma-impl.sublime-workspace b/ma-impl.sublime-workspace index badf5beb..9e358ffc 100644 --- a/ma-impl.sublime-workspace +++ b/ma-impl.sublime-workspace @@ -3,6 +3,10 @@ { "selected_items": [ + [ + "TOMCAT", + "TOMCAT_MINOR" + ], [ "faga", "fagales" @@ -272,10 +276,10 @@ "buffers": [ { - "file": "/home/eike/.local/share/vipra/jgibb/jgibb.tassign", + "file": "vm/bootstrap.sh", "settings": { - "buffer_size": 17796, + "buffer_size": 3519, "line_ending": "Unix" } } @@ -457,10 +461,19 @@ }, "expanded_folders": [ - "/home/eike/Repositories/fu/ss15/ma/impl" + "/home/eike/repos/master/ma-impl", + "/home/eike/repos/master/ma-impl/vm" ], "file_history": [ + "/usr/share/applications/defaults.list", + "/home/eike/repos/master/ma-impl/vm/config/initd-mongod", + "/home/eike/repos/master/ma-impl/vm/webapps/vipra-rest/WEB-INF/web.xml", + "/core", + "/home/eike/repos/master/ma-impl/vm/bootstrap.sh", + "/home/eike/repos/master/ma-impl/vm/config/environment", + "/home/eike/repos/master/ma-impl/Vagrantfile", + "/home/eike/repos/master/ma-impl/vm/config/initd-tomcat", "/home/eike/.local/share/vipra/jgibb/jgibb.tassign", "/home/eike/.local/share/vipra/jgibb/jgibb.twords", "/home/eike/Repositories/fu/ss15/ma/impl/TODO", @@ -580,18 +593,11 @@ "/home/eike/Repositories/fu/ss15/bfm/exercise-04/ex04.txt", "/home/eike/Repositories/fu/ss15/bfm/exercise-05/ex05.txt", "/home/eike/Repositories/fu/ss15/ki/exercise-08/native.pl", - "/home/eike/Repositories/fu/ss15/ki/exercise-08/birds.nkb", - "/home/eike/Repositories/fu/ss15/ki/exercise-08/task2b-tree.pl", - "/home/eike/Repositories/fu/ss15/ki/exercise-08/meta.pl", - "/home/eike/Repositories/fu/ss15/ki/exercise-08/task011.pl", - "/home/eike/Downloads/SchemaBasedEditor/README.md", - "/home/eike/Downloads/SchemaBasedEditor/textedit.cpp", - "/home/eike/.config/sublime-text-3/Packages/JSHint Gutter/JSHint.sublime-settings", - "/home/eike/.config/sublime-text-3/Packages/Default/Default (Linux).sublime-keymap" + "/home/eike/Repositories/fu/ss15/ki/exercise-08/birds.nkb" ], "find": { - "height": 36.0 + "height": 25.0 }, "find_in_files": { @@ -636,6 +642,7 @@ "case_sensitive": false, "find_history": [ + "gedit.desktop", "00:00Z\" },", "{ \"$date\": ", ".000+0000", @@ -762,8 +769,7 @@ "intended", "redirect_intended", "amount-in", - "'", - "!important" + "'" ], "highlight": true, "in_selection": false, @@ -771,6 +777,7 @@ "regex": false, "replace_history": [ + "sublime_text.desktop", "00:00Z\",", "", "Z", @@ -897,8 +904,7 @@ "@append$1", "survey", "SurveysController", - "", - "/assets" + "" ], "reverse": false, "show_context": true, @@ -914,86 +920,24 @@ [ { "buffer": 0, - "file": "/home/eike/.local/share/vipra/jgibb/jgibb.tassign", + "file": "vm/bootstrap.sh", "semi_transient": false, "settings": { - "buffer_size": 17796, + "buffer_size": 3519, "regions": { }, "selection": [ [ - 4764, - 4764 + 933, + 933 ] ], "settings": { - "BracketHighlighterBusy": false, - "bh_regions": - [ - "bh_angle", - "bh_angle_center", - "bh_angle_open", - "bh_angle_close", - "bh_angle_content", - "bh_c_define", - "bh_c_define_center", - "bh_c_define_open", - "bh_c_define_close", - "bh_c_define_content", - "bh_curly", - "bh_curly_center", - "bh_curly_open", - "bh_curly_close", - "bh_curly_content", - "bh_regex", - "bh_regex_center", - "bh_regex_open", - "bh_regex_close", - "bh_regex_content", - "bh_square", - "bh_square_center", - "bh_square_open", - "bh_square_close", - "bh_square_content", - "bh_double_quote", - "bh_double_quote_center", - "bh_double_quote_open", - "bh_double_quote_close", - "bh_double_quote_content", - "bh_round", - "bh_round_center", - "bh_round_open", - "bh_round_close", - "bh_round_content", - "bh_unmatched", - "bh_unmatched_center", - "bh_unmatched_open", - "bh_unmatched_close", - "bh_unmatched_content", - "bh_single_quote", - "bh_single_quote_center", - "bh_single_quote_open", - "bh_single_quote_close", - "bh_single_quote_content", - "bh_default", - "bh_default_center", - "bh_default_open", - "bh_default_close", - "bh_default_content", - "bh_tag", - "bh_tag_center", - "bh_tag_open", - "bh_tag_close", - "bh_tag_content" - ], - "incomplete_sync": null, - "remote_loading": false, - "synced": false, - "syntax": "Packages/Text/Plain text.tmLanguage" + "syntax": "Packages/ShellScript/Shell-Unix-Generic.tmLanguage" }, "translation.x": 0.0, "translation.y": 0.0, @@ -1007,7 +951,7 @@ ], "incremental_find": { - "height": 36.0 + "height": 25.0 }, "input": { @@ -1052,7 +996,7 @@ "project": "ma-impl.sublime-project", "replace": { - "height": 64.0 + "height": 66.0 }, "save_all_on_build": true, "select_file": diff --git a/vipra-cmd/pom.xml b/vipra-cmd/pom.xml index d07d0776..9d81925e 100644 --- a/vipra-cmd/pom.xml +++ b/vipra-cmd/pom.xml @@ -94,5 +94,12 @@ <artifactId>junit</artifactId> <version>4.12</version> </dependency> + + <!-- Workspace --> + <dependency> + <groupId>de.vipra</groupId> + <artifactId>util</artifactId> + <version>0.0.1-SNAPSHOT</version> + </dependency> </dependencies> </project> diff --git a/vipra-rest/pom.xml b/vipra-rest/pom.xml index 9f0dedb9..bb719431 100644 --- a/vipra-rest/pom.xml +++ b/vipra-rest/pom.xml @@ -93,6 +93,7 @@ <version>4.12</version> </dependency> + <!-- Workspace --> <dependency> <groupId>de.vipra</groupId> <artifactId>util</artifactId> diff --git a/vipra-ui/app/routes/articles/list.js b/vipra-ui/app/routes/articles/list.js index 81b69808..1428ecf3 100644 --- a/vipra-ui/app/routes/articles/list.js +++ b/vipra-ui/app/routes/articles/list.js @@ -40,7 +40,7 @@ export default Ember.Route.extend({ afterModel(model) { var count = {}; model.articles.forEach(article => { - var date = article.get('date') + var date = article.get('date'); var month = date.getMonth()+1; var dstr = date.getFullYear() + '-' + (month < 10 ? '0' + month : month); if(count.hasOwnProperty(dstr)) { diff --git a/vipra-ui/bower.json b/vipra-ui/bower.json index e011d589..20dcadec 100644 --- a/vipra-ui/bower.json +++ b/vipra-ui/bower.json @@ -4,14 +4,14 @@ "ember": "2.2.0", "ember-cli-shims": "0.0.6", "ember-cli-test-loader": "0.2.1", - "ember-data": "^2.2.1", + "ember-data": "2.2.1", "ember-load-initializers": "0.1.7", "ember-qunit": "0.4.16", - "ember-load-initializers": "0.1.7", "ember-qunit-notifications": "0.1.0", - "ember-resolver": "~0.1.20", - "jquery": "^1.11.3", + "ember-resolver": "0.1.20", + "jquery": "1.11.3", "loader.js": "ember-cli/loader.js#3.5.0", - "qunit": "~1.20.0" + "qunit": "1.20.0", + "highcharts": "4.2.1" } } diff --git a/vipra-ui/package.json b/vipra-ui/package.json index fa584f24..54be369a 100644 --- a/vipra-ui/package.json +++ b/vipra-ui/package.json @@ -35,6 +35,6 @@ "ember-data": "1.13.15", "ember-disable-proxy-controllers": "^1.0.1", "ember-export-application-global": "^1.0.4", - "ember-highcharts": "0.2.1" + "ember-highcharts": "0.3.0" } } diff --git a/vm/bootstrap.sh b/vm/bootstrap.sh index dac91121..bfaa0b1c 100644 --- a/vm/bootstrap.sh +++ b/vm/bootstrap.sh @@ -6,21 +6,31 @@ CONFIG=$VMDIR/config # ----------------------------------------------------------------------------- # add repos + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927 echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list # ----------------------------------------------------------------------------- # upgrade system + apt-get update apt-get upgrade -y # ----------------------------------------------------------------------------- # install packages + apt-get install git gdebi-core openjdk-7-jdk openjdk-7-jre -y # ----------------------------------------------------------------------------- # install mongodb + apt-get install -y mongodb-org +ln -sf $CONFIG/mongod.conf /etc/mongod.conf + +# setup startup script +cp $CONFIG/initd-mongod /etc/init.d/mongod +chmod 755 /etc/init.d/mongod +update-rc.d mongod defaults # disable hugepages (https://docs.mongodb.org/manual/tutorial/transparent-huge-pages/) cp $CONFIG/disable-transparent-hugepages /etc/init.d/ @@ -34,6 +44,7 @@ service mongod restart # ----------------------------------------------------------------------------- # install mongo express + apt-get install npm libkrb5-dev ln -sf $(which nodejs) /bin/node npm install -g mongo-express forever @@ -43,30 +54,33 @@ ln -sf $CONFIG/mongo-express.config.js /usr/local/lib/node_modules/mongo-express # install tomcat TOMCAT_MAJOR="8" -TOMCAT_MINOR="0.30" -TOMCAT_VERSION="$TOMCAT_MAJOR.$TOMCAT_MINOR" -TOMCAT_ROOT=/usr/share/tomcat$TOMCAT_MAJOR +TOMCAT_VERSION="$TOMCAT_MAJOR.0.30" +TOMCAT_ROOT=/usr/share/tomcat wget http://mirror.netcologne.de/apache.org/tomcat/tomcat-$TOMCAT_MAJOR/v$TOMCAT_VERSION/bin/apache-tomcat-$TOMCAT_VERSION.tar.gz tar zxf apache-tomcat-$TOMCAT_VERSION.tar.gz rm apache-tomcat-$TOMCAT_VERSION.tar.gz mv apache-tomcat-$TOMCAT_VERSION $TOMCAT_ROOT -ln -s $TOMCAT_ROOT /usr/share/tomcat + # set permissions -chown -R vagrant:vagrant /usr/share/tomcat -chmod +x /usr/share/tomcat/bin/*.sh +chown -R vagrant:vagrant $TOMCAT_ROOT +chmod +x $TOMCAT_ROOT/bin/*.sh + # setup startup script cp $CONFIG/initd-tomcat /etc/init.d/tomcat chmod 755 /etc/init.d/tomcat update-rc.d tomcat defaults + # move webapps dir -mv /usr/share/tomcat/webapps $VMDIR/webapps -ln -s $VMDIR/webapps /usr/share/tomcat/webapps +mv $TOMCAT_ROOT/webapps $VMDIR +ln -s $VMDIR/webapps $TOMCAT_ROOT/webapps + # start tomcat service tomcat start # ----------------------------------------------------------------------------- # install elasticsearch + wget https://download.elasticsearch.org/elasticsearch/release/org/elasticsearch/distribution/deb/elasticsearch/2.1.1/elasticsearch-2.1.1.deb gdebi -n elasticsearch-2.1.1.deb rm elasticsearch-2.1.1.deb @@ -74,14 +88,17 @@ service elasticsearch start # ----------------------------------------------------------------------------- # disable firewall + ufw disable # ----------------------------------------------------------------------------- # set environment + cat $CONFIG/environment >> /etc/environment # ----------------------------------------------------------------------------- # cleanup + apt-get autoremove -y apt-get clean dd if=/dev/zero of=/EMPTY bs=1M diff --git a/vm/config/initd-mongod b/vm/config/initd-mongod new file mode 100644 index 00000000..780e488b --- /dev/null +++ b/vm/config/initd-mongod @@ -0,0 +1,267 @@ +#!/bin/sh +# +# init.d script with LSB support. +# +# Copyright (c) 2007 Javier Fernandez-Sanguino <jfs@debian.org> +# +# This is free software; you may redistribute it and/or modify +# it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, +# or (at your option) any later version. +# +# This is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License with +# the Debian operating system, in /usr/share/common-licenses/GPL; if +# not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA +# +### BEGIN INIT INFO +# Provides: mongod +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs +# Should-Start: $named +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: An object/document-oriented database +# Description: MongoDB is a high-performance, open source, schema-free +# document-oriented data store that's easy to deploy, manage +# and use. It's network accessible, written in C++ and offers +# the following features: +# +# * Collection oriented storage - easy storage of object- +# style data +# * Full index support, including on inner objects +# * Query profiling +# * Replication and fail-over support +# * Efficient storage of binary data including large +# objects (e.g. videos) +# * Automatic partitioning for cloud-level scalability +# +# High performance, scalability, and reasonable depth of +# functionality are the goals for the project. +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/bin/mongod +DESC=database + +NAME=mongod +# Defaults. Can be overridden by the /etc/default/$NAME +# Other configuration options are located in $CONF file. See here for more: +# http://dochub.mongodb.org/core/configurationoptions +CONF=/etc/mongod.conf +PIDFILE=/var/run/$NAME.pid +ENABLE_MONGOD=yes + +# Include mongodb defaults if available +if [ -f /etc/default/$NAME ] ; then + . /etc/default/$NAME +fi + +# Handle NUMA access to CPUs (SERVER-3574) +# This verifies the existence of numactl as well as testing that the command works +NUMACTL_ARGS="--interleave=all" +if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null +then + NUMACTL="`which numactl` -- $NUMACTL_ARGS" + DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"} +else + NUMACTL="" + DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"} +fi + +if test ! -x $DAEMON; then + echo "Could not find $DAEMON" + exit 0 +fi + +if test "x$ENABLE_MONGOD" != "xyes"; then + exit 0 +fi + +. /lib/lsb/init-functions + +STARTTIME=1 +DIETIME=10 # Time to wait for the server to die, in seconds + # If this value is set too low you might not + # let some servers to die gracefully and + # 'restart' will not work + +DAEMONUSER=${DAEMONUSER:-mongodb} +DAEMONGROUP=${DAEMONGROUP:-mongodb} + +set -e + +running_pid() { +# Check if a given process pid's cmdline matches a given name + pid=$1 + name=$2 + [ -z "$pid" ] && return 1 + [ ! -d /proc/$pid ] && return 1 + cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1 |cut -d : -f 1` + # Is this the expected server + [ "$cmd" != "$name" ] && return 1 + return 0 +} + +running() { +# Check if the process is running looking at /proc +# (works for all users) + + # No pidfile, probably no daemon present + [ ! -f "$PIDFILE" ] && return 1 + pid=`cat $PIDFILE` + running_pid $pid $DAEMON || return 1 + return 0 +} + +start_server() { + # Recommended ulimit values for mongod or mongos + # See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings + # + ulimit -f unlimited + ulimit -t unlimited + ulimit -v unlimited + ulimit -n 64000 + ulimit -m unlimited + + # In dash, ulimit takes -p for maximum user processes + # In bash, it's -u + if readlink /proc/$$/exe | grep -q dash + then + ulimit -p 64000 + else + ulimit -u 64000 + fi + + # Start the process using the wrapper + start-stop-daemon --background --start --quiet --pidfile $PIDFILE \ + --make-pidfile --chuid $DAEMONUSER:$DAEMONGROUP \ + --exec $NUMACTL $DAEMON $DAEMON_OPTS + errcode=$? + return $errcode +} + +stop_server() { +# Stop the process using the wrapper + start-stop-daemon --stop --quiet --pidfile $PIDFILE \ + --retry 300 \ + --user $DAEMONUSER \ + --exec $DAEMON + errcode=$? + return $errcode +} + +force_stop() { +# Force the process to die killing it manually + [ ! -e "$PIDFILE" ] && return + if running ; then + kill -15 $pid + # Is it really dead? + sleep "$DIETIME"s + if running ; then + kill -9 $pid + sleep "$DIETIME"s + if running ; then + echo "Cannot kill $NAME (pid=$pid)!" + exit 1 + fi + fi + fi + rm -f $PIDFILE +} + + +case "$1" in + start) + log_daemon_msg "Starting $DESC" "$NAME" + # Check if it's running first + if running ; then + log_progress_msg "apparently already running" + log_end_msg 0 + exit 0 + fi + if start_server ; then + # NOTE: Some servers might die some time after they start, + # this code will detect this issue if STARTTIME is set + # to a reasonable value + [ -n "$STARTTIME" ] && sleep $STARTTIME # Wait some time + if running ; then + # It's ok, the server started and is running + log_end_msg 0 + else + # It is not running after we did start + log_end_msg 1 + fi + else + # Either we could not start it + log_end_msg 1 + fi + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + if running ; then + # Only stop the server if we see it running + errcode=0 + stop_server || errcode=$? + log_end_msg $errcode + else + # If it's not running don't do anything + log_progress_msg "apparently not running" + log_end_msg 0 + exit 0 + fi + ;; + force-stop) + # First try to stop gracefully the program + $0 stop + if running; then + # If it's still running try to kill it more forcefully + log_daemon_msg "Stopping (force) $DESC" "$NAME" + errcode=0 + force_stop || errcode=$? + log_end_msg $errcode + fi + ;; + restart|force-reload) + log_daemon_msg "Restarting $DESC" "$NAME" + errcode=0 + stop_server || errcode=$? + # Wait some sensible amount, some server need this + [ -n "$DIETIME" ] && sleep $DIETIME + start_server || errcode=$? + [ -n "$STARTTIME" ] && sleep $STARTTIME + running || errcode=$? + log_end_msg $errcode + ;; + status) + + log_daemon_msg "Checking status of $DESC" "$NAME" + if running ; then + log_progress_msg "running" + log_end_msg 0 + else + log_progress_msg "apparently not running" + log_end_msg 1 + exit 1 + fi + ;; + # MongoDB can't reload its configuration. + reload) + log_warning_msg "Reloading $NAME daemon: not implemented, as the daemon" + log_warning_msg "cannot re-read the config file (use restart)." + ;; + + *) + N=/etc/init.d/$NAME + echo "Usage: $N {start|stop|force-stop|restart|force-reload|status}" >&2 + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/vm/config/mongod.conf b/vm/config/mongod.conf new file mode 100644 index 00000000..6ca9d657 --- /dev/null +++ b/vm/config/mongod.conf @@ -0,0 +1,41 @@ +# mongod.conf + +# for documentation of all options, see: +# http://docs.mongodb.org/manual/reference/configuration-options/ + +# Where and how to store data. +storage: + dbPath: /var/lib/mongodb + journal: + enabled: true +# engine: +# mmapv1: +# wiredTiger: + +# where to write logging data. +systemLog: + destination: file + logAppend: true + path: /var/log/mongodb/mongod.log + +# network interfaces +net: + port: 27017 + bindIp: 0.0.0.0 + + +#processManagement: + +#security: + +#operationProfiling: + +#replication: + +#sharding: + +## Enterprise-Only Options: + +#auditLog: + +#snmp: -- GitLab