Files
openobserve/src/cli
udev c09f2822e7 feat: custom config file path (#8464)
### **PR Type**
Enhancement

This feature adds a new cli argument to openobserve binary, i.e. -c
which allows user to pass in path to a config file, adding flexibility
to load env variables from different files. Earlier versions strictly
looked for .env file in the current directory.
If this flag is not specified when running o2, the default file path
(.env) from current directory will be used to load the config files.

This feature also adds a job to watch the config file. By default this
job will run every 30 seconds, and can be configured via
ZO_CONFIG_WATCHER_INTERVAL env variable. The watcher will watch the
config file and reload the config if any changes are detected. By
default the watcher watches .env file if no other file is configured
using -c flag.

___

### **Description**
- Add CLI config file path support

- Introduce config file path manager

- Implement auto config reload watcher

- Expose watcher interval configuration


___

### Diagram Walkthrough


```mermaid
flowchart LR
  CLI["CLI adds --config option"] -- "set path + reload" --> Manager["ConfigPathManager stores path/hash"]
  Manager -- "path available" --> Watcher["ConfigWatcher job (interval)"]
  Watcher -- "hash change" --> Reload["Reload dotenv + refresh configs"]
  Reload -- "update hash" --> Manager
  ConfigInit["Config init"] -- "load from path or .env discovery" --> Manager
```



<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><details><summary>7
files</summary><table>
<tr>
<td><strong>cli.rs</strong><dd><code>Add --config option and initial
reload handling</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-cb1eb3e74723d891353ccf1e2e5e0d246d2e78a5e69dbe4c73006ea8412d65e0">+16/-2</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>config.rs</strong><dd><code>Config loading via path,
hashing, and watcher interval</code>&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-9aeee4a74c0520daa40f9b81c7016f5b6b3254375b968dd7598e745630980d62">+44/-3</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>config_path_manager.rs</strong><dd><code>New config path and
hash manager</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-20874a97fbe99ee6fd692896482ad236916c5f813c3857f824fe0ff6e8afd72a">+64/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>lib.rs</strong><dd><code>Export config path manager
module</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-c1f72c148113548ea854a05d09e3576632fcd7367279563bf3f42f0aef5454e2">+1/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>mod.rs</strong><dd><code>Refactor enterprise config reload
helper</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-ca09c9c9b020049bdbc3382c466bfcca80daac92e98760d9a9a76172abf34049">+8/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

<tr>
<td><strong>config_watcher.rs</strong><dd><code>Add periodic config file
change watcher and reloader</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
</dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-598ec79e0686bf314514227cf1f0b1dc560770b0e056761d6a214289d2eeb7f2">+94/-0</a>&nbsp;
&nbsp; </td>

</tr>

<tr>
<td><strong>mod.rs</strong><dd><code>Wire up config watcher on job
init</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-f2e4c29b8eef22189ec704a832633c4bd135a24444f054864c98064bd0963681">+2/-0</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>

</table></details></td></tr><tr><td><strong>Documentation</strong></td><td><details><summary>1
files</summary><table>
<tr>
<td><strong>pausable_job.rs</strong><dd><code>Improve macro
documentation punctuation</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp; &nbsp; </dd></td>
<td><a
href="https://github.com/openobserve/openobserve/pull/8464/files#diff-7e2dce7a3942789804bae659939c214c4eeb68d89315e23a08139214c339ea24">+3/-3</a>&nbsp;
&nbsp; &nbsp; </td>

</tr>
</table></details></td></tr></tr></tbody></table>

</details>

___
2025-09-18 16:34:05 +05:30
..
2025-08-22 21:05:46 +05:30