Skip to content

Commit

Permalink
Merge cba64f1 into 7ffce30
Browse files Browse the repository at this point in the history
  • Loading branch information
avara1986 committed Oct 17, 2020
2 parents 7ffce30 + cba64f1 commit 413d189
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
26 changes: 26 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,3 +167,29 @@ spec:
```

See [Routing](routing.md) and [Examples](examples.md) to continue with this tutorial

## Reload configuration without stopping your services

In a production environment you may need to change the microservice's configuration without restarting it.

PyMS has a feature to reload the configuration:

```
curl -X POST http://localhost:5000/reload-config
```

This endpoint calls the method `Microservice.reload_conf()`, which restarts the services,
the encryption configuration and initializes `create_app`.

```python
def reload_conf(self):
self.delete_services()
self.config.reload()
self.services = []
self.init_services()
self.crypt.config.reload()
self.create_app()
```

This means that your libraries will be restarted, which is why it's important to initialize your BD,
your configuration inside `init_libs` method. See more info [how to use Microservice class in this link](ms_class.md)
3 changes: 2 additions & 1 deletion pyms/utils/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,6 @@ def _get_conf_from_file(self, path, fn=None):
return files_cached[path]

def reload(self, fn=None):
files_cached.pop(self.path, None)
path = self.path or self.get_path_from_env()
files_cached.pop(path, None)
return self.get_file(fn)

0 comments on commit 413d189

Please sign in to comment.