From 36e589b826886b38ee046b7022a5d74b61c470ab Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Tue, 27 Sep 2016 15:30:41 +0200 Subject: [PATCH] library/roles/orientdb: Add the configuration files management. --- orientdb/defaults/main.yml | 4 + orientdb/tasks/main.yml | 11 +++ orientdb/templates/hazelcast.xml.j2 | 30 ++++++ .../templates/orientdb-server-config.xml.j2 | 91 +++++++++++++++++++ .../orientdb-server-log.properties.j2 | 46 ++++++++++ orientdb/templates/orientdb.init.j2 | 79 ++++++++++++++++ 6 files changed, 261 insertions(+) create mode 100644 orientdb/templates/hazelcast.xml.j2 create mode 100644 orientdb/templates/orientdb-server-config.xml.j2 create mode 100644 orientdb/templates/orientdb-server-log.properties.j2 create mode 100755 orientdb/templates/orientdb.init.j2 diff --git a/orientdb/defaults/main.yml b/orientdb/defaults/main.yml index 40cb329..ac332cf 100644 --- a/orientdb/defaults/main.yml +++ b/orientdb/defaults/main.yml @@ -6,3 +6,7 @@ orientdb_tar_file: '{{ orientdb_dir }}-{{ orientdb_version }}.tar.gz' orientdb_binary_distribution_url: 'http://orientdb.com/download.php?file={{ orientdb_tar_file }}' orientdb_user: orientdb orientdb_home_prefix: /home +orientdb_configuration_files: + - orientdb-server-log.properties + - orientdb-server-config.xml + - hazelcast.xml diff --git a/orientdb/tasks/main.yml b/orientdb/tasks/main.yml index 51a8a28..9f7acdf 100644 --- a/orientdb/tasks/main.yml +++ b/orientdb/tasks/main.yml @@ -18,5 +18,16 @@ become_user: '{{ orientdb_user }}' file: src={{ orientdb_dir }}-{{ orientdb_version }} dest={{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }} state=link + - name: Install the orientdb startup script + template: src=orientdb.init.j2 dest=/etc/init.d/orientdb owner=root group=root mode=0755 + + - name: Create a orientdb log directory out of the distribution directory + file: /var/log/orientdb state=directory owner={{ orientdb_user }} group={{ orientdb_user }} mode=0755 + + - name: Install the orientdb configuration files + become: True + become_user: '{{ orientdb_user }}' + template: src={{ item }}.j2 dest={{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }}/{{ item }} mode=0444 + tags: orientdb when: orientdb_install diff --git a/orientdb/templates/hazelcast.xml.j2 b/orientdb/templates/hazelcast.xml.j2 new file mode 100644 index 0000000..9893262 --- /dev/null +++ b/orientdb/templates/hazelcast.xml.j2 @@ -0,0 +1,30 @@ + + + + + + orientdb + orientdb + + + 2434 + + + 235.1.1.1 + 2434 + + + + + 16 + + diff --git a/orientdb/templates/orientdb-server-config.xml.j2 b/orientdb/templates/orientdb-server-config.xml.j2 new file mode 100644 index 0000000..f028f9a --- /dev/null +++ b/orientdb/templates/orientdb-server-config.xml.j2 @@ -0,0 +1,91 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + diff --git a/orientdb/templates/orientdb-server-log.properties.j2 b/orientdb/templates/orientdb-server-log.properties.j2 new file mode 100644 index 0000000..25190bc --- /dev/null +++ b/orientdb/templates/orientdb-server-log.properties.j2 @@ -0,0 +1,46 @@ +# +# /* +# * Copyright 2014 Orient Technologies LTD (info(at)orientechnologies.com) +# * +# * Licensed under the Apache License, Version 2.0 (the "License"); +# * you may not use this file except in compliance with the License. +# * You may obtain a copy of the License at +# * +# * http://www.apache.org/licenses/LICENSE-2.0 +# * +# * Unless required by applicable law or agreed to in writing, software +# * distributed under the License is distributed on an "AS IS" BASIS, +# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# * See the License for the specific language governing permissions and +# * limitations under the License. +# * +# * For more information: http://www.orientechnologies.com +# */ +# + +# Specify the handlers to create in the root logger +# (all loggers are children of the root logger) +# The following creates two handlers +handlers = java.util.logging.ConsoleHandler, java.util.logging.FileHandler + +# Set the default logging level for the root logger +.level = INFO +com.orientechnologies.level = INFO +com.orientechnologies.orient.server.distributed.level = INFO + +# Set the default logging level for new ConsoleHandler instances +java.util.logging.ConsoleHandler.level = INFO +# Set the default formatter for new ConsoleHandler instances +java.util.logging.ConsoleHandler.formatter = com.orientechnologies.common.log.OAnsiLogFormatter + +# Set the default logging level for new FileHandler instances +java.util.logging.FileHandler.level = INFO +# Naming style for the output file +java.util.logging.FileHandler.pattern=../log/orient-server.log +# Set the default formatter for new FileHandler instances +java.util.logging.FileHandler.formatter = com.orientechnologies.common.log.OLogFormatter +# Limiting size of output file in bytes: +java.util.logging.FileHandler.limit=10000000 +# Number of output files to cycle through, by appending an +# integer to the base file name: +java.util.logging.FileHandler.count=10 diff --git a/orientdb/templates/orientdb.init.j2 b/orientdb/templates/orientdb.init.j2 new file mode 100755 index 0000000..a84405f --- /dev/null +++ b/orientdb/templates/orientdb.init.j2 @@ -0,0 +1,79 @@ +#!/bin/sh +# OrientDB service script +# +# Copyright (c) Orient Technologies LTD (http://www.orientechnologies.com) + +# chkconfig: 2345 20 80 +# description: OrientDb init script +# processname: orientdb.sh + +# You have to SET the OrientDB installation directory here +ORIENTDB_DIR="{{ orientdb_home_prefix }}/{{ orientdb_user }}/{{ orientdb_dir }}" +ORIENTDB_USER="{{ orientdb_user }}" + +usage() { + echo "Usage: `basename $0`: " + exit 1 +} + +start() { + status + if [ $PID -gt 0 ] + then + echo "OrientDB server daemon was already started. PID: $PID" + return $PID + fi + echo "Starting OrientDB server daemon..." + cd "$ORIENTDB_DIR/bin" + su $ORIENTDB_USER -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup ./server.sh 1>../log/orientdb.log 2>../log/orientdb.err &" +} + +stop() { + status + if [ $PID -eq 0 ] + then + echo "OrientDB server daemon is already not running" + return 0 + fi + echo "Stopping OrientDB server daemon..." + cd "$ORIENTDB_DIR/bin" + su $ORIENTDB_USER -c "cd \"$ORIENTDB_DIR/bin\"; /usr/bin/nohup ./shutdown.sh 1>>../log/orientdb.log 2>>../log/orientdb.err &" +} + +status() { + PID=` ps auxw | grep 'orientdb.www.path' | grep java | grep -v grep | awk '{print $2}'` + if [ "x$PID" = "x" ] + then + PID=0 + fi + + # if PID is greater than 0 then OrientDB is running, else it is not + return $PID +} + +if [ "x$1" = "xstart" ] +then + start + exit 0 +fi + +if [ "x$1" = "xstop" ] +then + stop + exit 0 +fi + +if [ "x$1" = "xstatus" ] +then + status + if [ $PID -gt 0 ] + then + echo "OrientDB server daemon is running with PID: $PID" + exit 0 + else + echo "OrientDB server daemon is NOT running" + exit 3 + fi +fi + +usage