Edited Jython files are loaded more than once


(Erik Martens) #1

First of all, I would like to thank everybody involved to openHAB and especially
those who made jsr223-scripting possible.
While there are good points for openHAB DSL, there are some tasks where
jsr223-scripting seems to be more appropriate.
I discovered this topic not long ago, so I consider myself a NewBie.

Here is my challenge:
Edited Files appear in the Log as if they are running more than once, see an example here .
openHAB is running on a Debian 8 VM, apt install. Hardware of the Host is an intel i7. The configuration is edited from Mac OS X via a samba share configured as below

[openhab_production_basic_conf]
   path = /home/smarthomeadmin/src
   read only = no
   guest ok = no
   force user = smarthomeadmin
   force group = openhab
   valid users = smarthomeadmin

the Logging configuration (/var/lib/openhab2/etc/org.ops4j.pax.logging.cfg) is

# Common pattern layout for appenders
#log4j2.pattern = %d{ISO8601} | %-5p | %-16t | %-32c{1} | %X{bundle.id} - %X{bundle.name} - %X{bundle.version} | %m%n

# Root logger
log4j2.rootLogger.level = WARN
log4j2.rootLogger.appenderRefs = out, osgi
log4j2.rootLogger.appenderRef.out.ref = LOGFILE
log4j2.rootLogger.appenderRef.osgi.ref = OSGI

# Karaf Shell logger
log4j2.logger.shell.name = org.apache.karaf.shell.support
log4j2.logger.shell.level = OFF
log4j2.logger.shell.appenderRefs = stdout
log4j2.logger.shell.appenderRef.stdout.ref = STDOUT

# Security audit logger
log4j2.logger.audit.name = org.apache.karaf.jaas.modules.audit
log4j2.logger.audit.level = INFO
log4j2.logger.audit.additivity = false
log4j2.logger.audit.appenderRefs = audit
log4j2.logger.audit.appenderRef.audit.ref = AUDIT

# openHAB specific logger configuration

log4j2.logger.openhab.name = org.openhab
log4j2.logger.openhab.level = INFO

log4j2.logger.smarthome.name = org.eclipse.smarthome
log4j2.logger.smarthome.level = INFO

log4j2.logger.smarthomeItemStateEvent.name = smarthome.event.ItemStateEvent
log4j2.logger.smarthomeItemStateEvent.level = ERROR
log4j2.logger.smarthomeItemAddedEvent.name = smarthome.event.ItemAddedEvent
log4j2.logger.smarthomeItemAddedEvent.level = ERROR
log4j2.logger.smarthomeItemRemovedEvent.name = smarthome.event.ItemRemovedEvent
log4j2.logger.smarthomeItemRemovedEvent.level = ERROR
log4j2.logger.smarthomeThingStatusInfoEvent.name = smarthome.event.ThingStatusInfoEvent
log4j2.logger.smarthomeThingStatusInfoEvent.level = ERROR
log4j2.logger.smarthomeThingAddedEvent.name = smarthome.event.ThingAddedEvent
log4j2.logger.smarthomeThingAddedEvent.level = ERROR
log4j2.logger.smarthomeThingRemovedEvent.name = smarthome.event.ThingRemovedEvent
log4j2.logger.smarthomeThingRemovedEvent.level = ERROR
log4j2.logger.smarthomeInboxUpdatedEvent.name = smarthome.event.InboxUpdatedEvent
log4j2.logger.smarthomeInboxUpdatedEvent.level = ERROR

###############################################################################
# Changes for smarthomebbb.lan
###############################################################################
log4j2.logger.smarthomeItemCommandEvent.name = smarthome.event.ItemCommandEvent
log4j2.logger.smarthomeItemCommandEvent.level = INFO
log4j2.logger.smarthomeItemCommandEvent.additivity = false
log4j2.logger.smarthomeItemCommandEvent.appenderRefs = console
log4j2.logger.smarthomeItemCommandEvent.appenderRef.console.ref = STDOUT
log4j2.logger.smarthomeItemStateChangedEvent.name = smarthome.event.ItemStateChangedEvent
log4j2.logger.smarthomeItemStateChangedEvent.level = INFO
log4j2.logger.smarthomeItemStateChangedEvent.additivity = false
log4j2.logger.smarthomeItemStateChangedEvent.appenderRefs = console
log4j2.logger.smarthomeItemStateChangedEvent.appenderRef.console.ref = STDOUT

# openHAB Scripts and Rules General
log4j2.logger.smarthomeScript.name = org.eclipse.smarthome.model.script
log4j2.logger.smarthomeScript.level = DEBUG
log4j2.logger.smarthomeScript.appenderRefs = console
log4j2.logger.smarthomeScript.appenderRef.console.ref = STDOUT

# This are line like "Scheduled code for execution at 2018-01-27T08:54:26.376+01:00"
log4j2.logger.smarthomeScriptActions.name = org.eclipse.smarthome.model.script.actions.ScriptExecution
log4j2.logger.smarthomeScriptActions.level = INFO
# This are line like "Executing timer 'DEFAULT.2018-01-27T08:53:24.822+01:00: Proxy for org.eclipse.xtext.xbase.lib.Procedures$Procedure0: [ | {
log4j2.logger.smarthomeScriptActionsTimer.name = org.eclipse.smarthome.model.script.internal.actions.TimerExecutionJob
log4j2.logger.smarthomeScriptActionsTimer.level = INFO

# openHAB Scripts and Rules on Subpackage Level
log4j2.logger.smarthomeScript_dev_wave.name = org.eclipse.smarthome.model.script.dev_wave
log4j2.logger.smarthomeScript_dev_wave.level = INFO
log4j2.logger.smarthomeScript_hlk_ww.name = org.eclipse.smarthome.model.script.hlk_ww
log4j2.logger.smarthomeScript_hlk_ww.level = INFO

###############################################################################
# End changes for smarthomebbb.lan
###############################################################################

log4j2.logger.events.name = smarthome.event
log4j2.logger.events.level = INFO
log4j2.logger.events.additivity = false
log4j2.logger.events.appenderRefs = event
log4j2.logger.events.appenderRef.event.ref = EVENT
log4j2.logger.events.appenderRef.osgi.ref = OSGI

log4j2.logger.jupnp.name = org.jupnp
log4j2.logger.jupnp.level = ERROR

log4j2.logger.jmdns.name = javax.jmdns
log4j2.logger.jmdns.level = ERROR

# This suppresses all Maven download issues from the log when doing feature installations
# as we are logging errors ourselves in a nicer way anyhow.
log4j2.logger.paxurl.name = org.ops4j.pax.url.mvn.internal.AetherBasedResolver
log4j2.logger.paxurl.level = ERROR

# Filters known issues of pax-web (issue link to be added here).
# Can be removed once the issues are resolved in an upcoming version.
log4j2.logger.paxweb.name = org.ops4j.pax.web.pax-web-runtime
log4j2.logger.paxweb.level = OFF

# Filters known issues of lsp4j, see
# https://github.com/eclipse/smarthome/issues/4639
# https://github.com/eclipse/smarthome/issues/4629
# https://github.com/eclipse/smarthome/issues/4643
# Can be removed once the issues are resolved in an upcoming version.
log4j2.logger.lsp4j.name = org.eclipse.lsp4j
log4j2.logger.lsp4j.level = OFF

# Filters known issues of KarServiceImpl, see
# https://github.com/openhab/openhab-distro/issues/519#issuecomment-351944506
# Can be removed once the issues are resolved in an upcoming version.
log4j2.logger.karservice.name = org.apache.karaf.kar.internal.KarServiceImpl
log4j2.logger.karservice.level = ERROR

# Appenders configuration

# Console appender not used by default (see log4j2.rootLogger.appenderRefs)
log4j2.appender.console.type = Console
log4j2.appender.console.name = STDOUT
log4j2.appender.console.layout.type = PatternLayout
log4j2.appender.console.layout.pattern = %d{HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n

# Rolling file appender
log4j2.appender.out.type = RollingRandomAccessFile
log4j2.appender.out.name = LOGFILE
log4j2.appender.out.fileName = ${openhab.logdir}/openhab.log
log4j2.appender.out.filePattern = ${openhab.logdir}/openhab.log.%i
log4j2.appender.out.immediateFlush = true
log4j2.appender.out.append = true
log4j2.appender.out.layout.type = PatternLayout
log4j2.appender.out.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j2.appender.out.policies.type = Policies
log4j2.appender.out.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.out.policies.size.size = 16MB

# Event log appender
log4j2.appender.event.type = RollingRandomAccessFile
log4j2.appender.event.name = EVENT
log4j2.appender.event.fileName = ${openhab.logdir}/events.log
log4j2.appender.event.filePattern = ${openhab.logdir}/events.log.%i
log4j2.appender.event.immediateFlush = true
log4j2.appender.event.append = true
log4j2.appender.event.layout.type = PatternLayout
log4j2.appender.event.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-26.26c] - %m%n
log4j2.appender.event.policies.type = Policies
log4j2.appender.event.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.event.policies.size.size = 16MB

# Audit file appender
log4j2.appender.audit.type = RollingRandomAccessFile
log4j2.appender.audit.name = AUDIT
log4j2.appender.audit.fileName = ${openhab.logdir}/audit.log
log4j2.appender.audit.filePattern = ${openhab.logdir}/audit.log.%i
log4j2.appender.audit.append = true
log4j2.appender.audit.layout.type = PatternLayout
log4j2.appender.audit.layout.pattern = %d{yyyy-MM-dd HH:mm:ss.SSS} [%-5.5p] [%-36.36c] - %m%n
log4j2.appender.audit.policies.type = Policies
log4j2.appender.audit.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.audit.policies.size.size = 8MB

# OSGi appender
log4j2.appender.osgi.type = PaxOsgi
log4j2.appender.osgi.name = OSGI
log4j2.appender.osgi.filter = *

Any hint is appreciated.


(steve1) #2

The JSR223 code uses the same file watcher as the other components in openHAB2. Therefore, it’s unlikely that this issue specific to JSR223. In the past, I’ve seen issues with using samba and files changes being detected too quickly (before the entire file was written) or triggering multiple file loads. I always edit my files using ssh now so I haven’t seen the issue for quite some time. The behavior you are seeing may (or may not) have a similar cause.


(Sebastian) #3

I have the same problem using pycharm, but when I edit the files with notepad++ it is loaded correctly (only once).


(Erik Martens) #4

Thank you for your replies, @steve1 and @Spaceman_Spiff!
When posting the issue, I was editing my configuration with ESH Designer and its successor, openHAB VS Code Extension directly on my development system through a Samba share.

According to @steve1’s advice, I switched to local edits and then pushing the configuration with ssh. It took some time to set it up, but since that is done, edited files are loaded once (only, as it should be).

Additionally, the System behaves more predictable than before.