Skip to content

Commit

Permalink
Merge pull request #26 from Fiware/hardening/25_log_format
Browse files Browse the repository at this point in the history
Hardening/25 log format
  • Loading branch information
jesuspg committed Nov 3, 2014
2 parents 269f3ce + 1690b48 commit 2dd672b
Show file tree
Hide file tree
Showing 30 changed files with 591 additions and 365 deletions.
6 changes: 6 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Components
Releases
========

`FIWARE 4.1.1`_

- NGSI Event Broker version 1.4.0
- NGSI Adapter version 1.2.0

`FIWARE 3.5.2`_

- NGSI Event Broker version 1.3.1
Expand Down Expand Up @@ -76,6 +81,7 @@ License
.. REFERENCES
.. _FIWARE Catalogue - Monitoring GE: http://catalogue.fi-ware.org/enablers/monitoring-ge-tid-implementation
.. _FIWARE 4.1.1: https://forge.fi-ware.org/frs/?group_id=7&release_id=544#cloud-monitoring-4-1-1-title-content
.. _FIWARE 3.5.2: https://forge.fi-ware.org/frs/?group_id=7&release_id=529#cloud-monitoring-3-5-2-title-content
.. _FIWARE 3.5.1: https://forge.fi-ware.org/frs/?group_id=7&release_id=506#cloud-monitoring-3-5-1-title-content
.. _FIWARE 3.3.3: https://forge.fi-ware.org/frs/?group_id=7&release_id=419#cloud-monitoring-3-3-3-title-content
Expand Down
13 changes: 7 additions & 6 deletions ngsi_adapter/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ We can also start the adapter manually from the command line:
$ adapter
Context Broker URL, adapter listen port and other parameters may be supplied
as command line arguments, overriding the default values defined in
*config/options.js*:
Context Broker URL, adapter listen port, logging level and other parameters may
be supplied as command line arguments, overriding the default values defined
in *config/options.js*:

.. code::
Expand All @@ -57,9 +57,6 @@ run:
$ adapter --help
Logging options (such as level, console, rolling files, etc.) may be configured
editing *config/logger.js* file.

To modify the parameters to run the adapter as a service, please set variable
``DAEMON_ARGS`` in */etc/init.d/ngsi\_adapter* script.

Expand Down Expand Up @@ -90,6 +87,10 @@ an object *EntityData*.
Changelog
=========

Version 1.2.0

- Add new log format (issue #25)

Version 1.1.1

- Add .deb package generation (issue #16)
Expand Down
6 changes: 6 additions & 0 deletions ngsi_adapter/script/build/files/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
fiware-monitoring-ngsi-adapter (1.2.0) precise; urgency=low

* Included new log format (issue #25)

-- Telefónica I+D <[email protected]> Tue, 28 Oct 2014 11:45:00 +0200

fiware-monitoring-ngsi-adapter (1.1.1) precise; urgency=low

* Included Debian package generation (issue #16)
Expand Down
5 changes: 3 additions & 2 deletions ngsi_adapter/script/build/files/debian/ngsi_adapter.init
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="NGSI Adapter Service"
NAME=ngsi_adapter
DAEMON=/opt/fiware/$NAME/adapter
DAEMON=#DH_FIWARE_DIR#/$NAME/adapter
DAEMON_ARGS=""
DAEMON_USER=fiware
PIDFILE=/var/run/$NAME.pid
LOGFILE=#DH_LOGGING_DIR#/$NAME.log
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the component is not installed
Expand Down Expand Up @@ -62,7 +63,7 @@ do_start()
|| return 1
start-stop-daemon --start --quiet --pidfile $PIDFILE --make-pidfile \
--background --chuid $DAEMON_USER \
--startas $DAEMON -- $DAEMON_ARGS \
--startas /bin/sh -- -c "exec $DAEMON $DAEMON_ARGS >> $LOGFILE" \
|| return 2
}

Expand Down
13 changes: 5 additions & 8 deletions ngsi_adapter/script/build/files/debian/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ if [ "$1" = configure ]; then
adduser --quiet --ingroup $FIWARE_GRP \
--home /nonexistent --no-create-home \
--disabled-password --shell /bin/false \
--gecos "FI-WARE" $FIWARE_USR
--gecos "FIWARE" $FIWARE_USR
fi
# check ADAPTER user
if ! getent passwd $ADAPTER_USR >/dev/null; then
addgroup --quiet $ADAPTER_GRP 2>/dev/null || true
adduser --quiet --ingroup $ADAPTER_GRP \
--home /nonexistent --no-create-home \
--disabled-password --shell /bin/false \
--gecos "FI-WARE NGSI Adapter" $ADAPTER_USR
--gecos "FIWARE NGSI Adapter" $ADAPTER_USR
fi
# change directory ownership
chown -R $FIWARE_USR:$FIWARE_GRP $FIWARE_DIR
Expand All @@ -43,18 +43,15 @@ if [ "$1" = configure ]; then
# change file permissions
chmod -R g+w $ADAPTER_DIR
chmod a+x $ADAPTER_DIR/adapter
# change logging directory at config files
LOGGING_CONFIG=$ADAPTER_DIR/config/logger.js
sed -i "/logFile/ s:process.cwd():'$LOGGING_DIR':" $LOGGING_CONFIG
# postinstall message
if [ $STATUS -eq 0 ]; then fmt --width=${COLUMNS:-$(tput cols)} <<-EOF
NGSI Adapter successfully installed at $ADAPTER_DIR.
WARNING: Check configuration file $ADAPTER_DIR/config/options.js
and logging parameters at $ADAPTER_DIR/config/logger.js before
starting \`$ADAPTER_SRV' service. Please read Usage section at
README.rst for more details.
and logging parameters at /etc/init.d/$ADAPTER_SRV before
starting \`$ADAPTER_SRV' service. Please read Usage section
at README.rst for more details.
EOF
else fmt --width=${COLUMNS:-$(tput cols)} 1>&2 <<-EOF
Expand Down
5 changes: 3 additions & 2 deletions ngsi_adapter/script/build/files/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DH_LOGGING_DIR:=/var/log/$(DH_ADAPTER_SRV)
DH_NODE_REQ_VERSION:=$(shell awk '/"node":/ {split($$0,v,/["~=<>]/); print v[6]}' src/package.json)

# Function to substitute variable $(1) in file $(2)
dh_var_subst = $(shell sed -i 's:=\#$(1)\#:=$(value $(1)):' $(2))
dh_var_subst = $(shell sed -i 's:\#$(1)\#:$(value $(1)):' $(2))

%:
dh $@
Expand All @@ -29,10 +29,11 @@ override_dh_auto_build:

override_dh_install: DH_VARS=$(filter DH_%,$(.VARIABLES))
override_dh_install:
dh_install -Xtest -Xdebian -X.git -X.svn
dh_install -Xtest -Xreport -Xsite -Xnode_modules -Xdebian -X.git -X.svn -X.log
$(foreach var,$(DH_VARS),$(call dh_var_subst,$(var),debian/preinst))
$(foreach var,$(DH_VARS),$(call dh_var_subst,$(var),debian/postinst))
$(foreach var,$(DH_VARS),$(call dh_var_subst,$(var),debian/postrm))
$(foreach var,$(DH_VARS),$(call dh_var_subst,$(var),debian/$(DH_ADAPTER_SRV).init))

override_dh_installinit:
dh_installinit --name=$(DH_ADAPTER_SRV) --no-start
78 changes: 0 additions & 78 deletions ngsi_adapter/src/config/logger.js

This file was deleted.

6 changes: 5 additions & 1 deletion ngsi_adapter/src/config/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@
/**
* @namespace
* @property {Object} defaults Default values for configuration options.
* @property {String} defaults.logLevel Default logging level.
* @property {String} defaults.brokerUrl Default Context Broker URL.
* @property {String} defaults.listenHost Default adapter listen host.
* @property {Number} defaults.listenPort Default adapter listen port.
* @property {Number} defaults.retries Default maximum number of invocation retries.
*/
var defaults = {
logLevel: 'INFO',
brokerUrl: 'http://127.0.0.1:1026/',
listenHost: '127.0.0.1',
listenHost: '0.0.0.0',
listenPort: 1337,
retries: 2
};
Expand All @@ -45,12 +47,14 @@ var defaults = {
/**
* @namespace
* @property {Object} opts Command line options.
* @property {String} opts.logLevel Logging level.
* @property {String} opts.brokerUrl Context Broker URL.
* @property {String} opts.listenHost Adapter listen host.
* @property {Number} opts.listenPort Adapter listen port.
* @property {Number} opts.retries Maximum number of invocation retries.
*/
var opts = require('optimist')
.options('l', { alias: 'logLevel', 'default': defaults.logLevel, describe: 'Logging level' })
.options('b', { alias: 'brokerUrl', 'default': defaults.brokerUrl, describe: 'Context Broker URL' })
.options('H', { alias: 'listenHost', 'default': defaults.listenHost, describe: 'Adapter listen host' })
.options('p', { alias: 'listenPort', 'default': defaults.listenPort, describe: 'Adapter listen port' })
Expand Down
Loading

0 comments on commit 2dd672b

Please sign in to comment.