Alon Bar-Lev has uploaded a new change for review.

Change subject: packaging: engine-service: support outputing log to console
......................................................................

packaging: engine-service: support outputing log to console

This ease developer mode, as developer expect to see feedback from the
service.

Change-Id: I554072d771bb380ab8a5b1df748fced53961cf79
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M packaging/conf/engine.conf.defaults.in
M packaging/services/ovirt-engine-notifier.systemd.in
M packaging/services/ovirt-engine-notifier.sysv.in
M packaging/services/ovirt-engine.systemd.in
M packaging/services/ovirt-engine.sysv.in
M packaging/services/ovirt-engine.xml.in
M packaging/services/service.py
M packaging/setup/plugins/ovirt-engine-setup/config/jboss.py
8 files changed, 58 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/15169/1

diff --git a/packaging/conf/engine.conf.defaults.in 
b/packaging/conf/engine.conf.defaults.in
index bab73ea..4f2ceea 100644
--- a/packaging/conf/engine.conf.defaults.in
+++ b/packaging/conf/engine.conf.defaults.in
@@ -70,6 +70,11 @@
 ENGINE_DEBUG_ADDRESS=
 
 #
+# Set this if you wish to write engine log to console as well.
+#
+ENGINE_LOG_TO_CONSOLE=false
+
+#
 # Change following to true if you want to enable garbage collection debug
 # information (will be sent to the console.log file):
 #
diff --git a/packaging/services/ovirt-engine-notifier.systemd.in 
b/packaging/services/ovirt-engine-notifier.systemd.in
index eeaa2bb..45825b8 100644
--- a/packaging/services/ovirt-engine-notifier.systemd.in
+++ b/packaging/services/ovirt-engine-notifier.systemd.in
@@ -6,7 +6,7 @@
 Type=simple
 User=@ENGINE_USER@
 Group=@ENGINE_GROUP@
-ExecStart=@ENGINE_USR@/services/ovirt-engine-notifier.py $EXTRA_ARGS start
+ExecStart=@ENGINE_USR@/services/ovirt-engine-notifier.py --redirect-output 
$EXTRA_ARGS start
 EnvironmentFile=-/etc/sysconfig/ovirt-engine-notifier
 
 [Install]
diff --git a/packaging/services/ovirt-engine-notifier.sysv.in 
b/packaging/services/ovirt-engine-notifier.sysv.in
index b91c750..f1de639 100644
--- a/packaging/services/ovirt-engine-notifier.sysv.in
+++ b/packaging/services/ovirt-engine-notifier.sysv.in
@@ -40,6 +40,7 @@
                        "${ENGINE_USR}/services/${NAME}.py" \
                                --pidfile="${PIDFILE}" \
                                --background \
+                               --redirect-output \
                                ${EXTRA_ARGS} \
                                start
                RETVAL=$?
diff --git a/packaging/services/ovirt-engine.systemd.in 
b/packaging/services/ovirt-engine.systemd.in
index 5202abc..ccf191c 100644
--- a/packaging/services/ovirt-engine.systemd.in
+++ b/packaging/services/ovirt-engine.systemd.in
@@ -7,7 +7,7 @@
 User=@ENGINE_USER@
 Group=@ENGINE_GROUP@
 LimitNOFILE=65535
-ExecStart=@ENGINE_USR@/services/ovirt-engine.py $EXTRA_ARGS start
+ExecStart=@ENGINE_USR@/services/ovirt-engine.py --redirect-output $EXTRA_ARGS 
start
 EnvironmentFile=-/etc/sysconfig/ovirt-engine
 
 [Install]
diff --git a/packaging/services/ovirt-engine.sysv.in 
b/packaging/services/ovirt-engine.sysv.in
index c5cf52d..0a9af50 100644
--- a/packaging/services/ovirt-engine.sysv.in
+++ b/packaging/services/ovirt-engine.sysv.in
@@ -40,6 +40,7 @@
                        "${ENGINE_USR}/services/${NAME}.py" \
                                --pidfile="${PIDFILE}" \
                                --background \
+                               --redirect-output \
                                ${EXTRA_ARGS} \
                                start
                RETVAL=$?
diff --git a/packaging/services/ovirt-engine.xml.in 
b/packaging/services/ovirt-engine.xml.in
index eb39d2d..9d317d2 100644
--- a/packaging/services/ovirt-engine.xml.in
+++ b/packaging/services/ovirt-engine.xml.in
@@ -62,6 +62,14 @@
         <append value="true"/>
       </size-rotating-file-handler>
 
+      <!-- Console -->
+      <console-handler name="CONSOLE" autoflush="true">
+        <level name="INFO"/>
+        <formatter>
+          <pattern-formatter pattern="%d %-5p [%c] (%t) %s%E%n"/>
+        </formatter>
+      </console-handler>
+
       <!-- Loggers for the application server: -->
       <logger category="com.arjuna">
         <level name="WARN"/>
@@ -78,6 +86,9 @@
         <level name="INFO"/>
         <handlers>
           <handler name="ENGINE"/>
+          #if $getBoolean('ENGINE_LOG_TO_CONSOLE')
+              <handler name="CONSOLE"/>
+          #end if
         </handlers>
       </logger>
       <logger category="org.ovirt.engine.core.bll">
diff --git a/packaging/services/service.py b/packaging/services/service.py
index 5adb632..71ee606 100755
--- a/packaging/services/service.py
+++ b/packaging/services/service.py
@@ -479,7 +479,9 @@
 
         self.daemonSetup()
 
-        stdout, stderr = self.daemonStdHandles()
+        stdout, stderr = (sys.stdout, sys.stderr)
+        if self._options.redirectOutput:
+            stdout, stderr = self.daemonStdHandles()
 
         def _myterm(signum, frame):
             raise self.TerminateException()
@@ -534,11 +536,34 @@
             default=False,
             help=_('Go into the background'),
         )
+        parser.add_option(
+            '--redirect-output',
+            dest='redirectOutput',
+            action='store_true',
+            default=False,
+            help=_('Redirect output of daemon'),
+        )
         (self._options, args) = parser.parse_args()
 
         if self._options.debug:
             logging.getLogger('ovirt').setLevel(logging.DEBUG)
 
+        if not self._options.redirectOutput:
+            h = logging.StreamHandler()
+            h.setLevel(logging.DEBUG)
+            h.setFormatter(
+                logging.Formatter(
+                    fmt=(
+                        os.path.splitext(os.path.basename(sys.argv[0]))[0] +
+                        '[%(process)s] '
+                        '%(levelname)s '
+                        '%(funcName)s:%(lineno)d '
+                        '%(message)s'
+                    ),
+                ),
+            )
+            logging.getLogger('ovirt').addHandler(h)
+
         if len(args) != 1:
             parser.error(_('Action is missing'))
         action = args[0]
diff --git a/packaging/setup/plugins/ovirt-engine-setup/config/jboss.py 
b/packaging/setup/plugins/ovirt-engine-setup/config/jboss.py
index 95ec2a5..f6429c0 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/config/jboss.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/config/jboss.py
@@ -80,16 +80,21 @@
                 OVIRT_ENGINE_NOTIFIER_SERVICE_CONFIG_JBOSS
             ),
         ):
+            content = [
+                'JBOSS_HOME="{jbossHome}"'.format(
+                    jbossHome=self.environment[
+                        osetupcons.ConfigEnv.JBOSS_HOME
+                    ],
+                ),
+            ]
+            if self.environment[osetupcons.CoreEnv.DEVELOPER_MODE]:
+                content.append(
+                    'ENGINE_LOG_TO_CONSOLE=true'
+                )
             self.environment[otopicons.CoreEnv.MAIN_TRANSACTION].append(
                 filetransaction.FileTransaction(
                     name=f,
-                    content=(
-                        'JBOSS_HOME="{jbossHome}"\n'
-                    ).format(
-                        jbossHome=self.environment[
-                            osetupcons.ConfigEnv.JBOSS_HOME
-                        ],
-                    ),
+                    content=content,
                     modifiedList=self.environment[
                         otopicons.CoreEnv.MODIFIED_FILES
                     ],


--
To view, visit http://gerrit.ovirt.org/15169
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I554072d771bb380ab8a5b1df748fced53961cf79
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to