Skip to content

Commit

Permalink
Fix custom config path being ignored during reload (#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtomlinson committed May 15, 2020
1 parent 092b2bf commit 47efe84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
5 changes: 3 additions & 2 deletions opsdroid/cli/start.py
Expand Up @@ -32,11 +32,12 @@ def start(path):
"""
check_dependencies()

config = load_config_file([path] if path else DEFAULT_CONFIG_LOCATIONS)
config_path = [path] if path else DEFAULT_CONFIG_LOCATIONS
config = load_config_file(config_path)

configure_lang(config)
configure_logging(config)
welcome_message(config)

with OpsDroid(config=config) as opsdroid:
with OpsDroid(config=config, config_path=config_path) as opsdroid:
opsdroid.run()
13 changes: 4 additions & 9 deletions opsdroid/core.py
Expand Up @@ -12,7 +12,7 @@
from watchgod import awatch, PythonWatcher

from opsdroid import events
from opsdroid.const import DEFAULT_CONFIG_PATH
from opsdroid.const import DEFAULT_CONFIG_LOCATIONS
from opsdroid.memory import Memory
from opsdroid.connector import Connector
from opsdroid.configuration import load_config_file
Expand Down Expand Up @@ -44,7 +44,7 @@ class OpsDroid:

instances = []

def __init__(self, config=None):
def __init__(self, config=None, config_path=None):
"""Start opsdroid."""
self.bot_name = "opsdroid"
self._running = False
Expand All @@ -63,6 +63,7 @@ def __init__(self, config=None):
self.modules = {}
self.cron_task = None
self.loader = Loader(self)
self.config_path = [config_path] if config_path else DEFAULT_CONFIG_LOCATIONS
if config is None:
self.config = {}
else:
Expand Down Expand Up @@ -238,13 +239,7 @@ async def unload(self, future=None):
async def reload(self):
"""Reload opsdroid."""
await self.unload()
self.config = load_config_file(
[
"configuration.yaml",
DEFAULT_CONFIG_PATH,
"/etc/opsdroid/configuration.yaml",
]
)
self.config = load_config_file(self.config_path)
await self.load()

def setup_skills(self, skills):
Expand Down

0 comments on commit 47efe84

Please sign in to comment.