Confirming zero-downtime updates after changing the custom dictionary
Operations get tedious if you have to restart the server every time you edit the custom dictionary. Bareun applies dictionary file changes immediately without stopping the server. It watches file system events in real time, and it also checks periodically in case a change was missed.
This page explains how zero-downtime updates work and how to confirm that a change was applied.
How are changes applied without downtime?
Bareun applies dictionary changes in three overlapping layers. The earlier layer catches a change first, and if it misses, the next layer backs it up, so changes are applied without gaps even in production.
1. Applied immediately on an API call (default)
When you change a dictionary through a custom dictionary API such as UpdateCustomDictionary, the dictionary in memory is replaced right away. The server process where you updated the dictionary applies the new dictionary from the next request.
No waiting or restart is needed.
2. Multiple processes: applied immediately when an external file changes
When several processes (instances) share the same custom dictionary directory and one of them changes a dictionary, the other processes detect the file change and apply it immediately. The following file system events are watched.
| Event | When it occurs |
|---|---|
Write | A dictionary file's contents are modified |
Create | A new dictionary file is created |
Remove | A dictionary file is deleted |
3. 60-second safety net: guaranteed to apply
Even if a file system event was missed, or the environment has weak notifications such as an external mount, the 60-second periodic check catches up with the change. In other words, applying the change is guaranteed within 60 seconds at most in every case.
Why no restart is needed
When you update a dictionary with UpdateCustomDictionary, the in-memory dictionary is replaced as soon as the call is made. If several processes share the same directory, the other processes detect the file change and follow, and the 60-second check covers any missed events. The new dictionary is applied without cutting off requests in progress, so it is safe in production.
graph TD A["① API call (UpdateCustomDictionary)"] -->|Immediately| M["In-memory dictionary replaced<br>No downtime"]; B["② External file change (multiple processes)"] -->|File change detected immediately| M; C["③ 60-second periodic check (safety net)"] -->|Even missed changes within 60 seconds| M;
Confirming that a change was applied
The most reliable way to confirm is to analyze the word you changed.
from bareunpy import Tagger
my_tagger = Tagger('YOUR-API-KEY', 'localhost', port=5656)
# 1) Add a new word to the dictionary
cust_dic = my_tagger.custom_dict("trend")
cust_dic.copy_np_set({'신상밈'})
cust_dic.update()
# 2) Analyze right away to confirm it was applied
my_tagger.set_domain('trend')
res = my_tagger.tags(['신상밈이 유행한다.'])
for tok in res.msg().sentences[0].tokens:
for m in tok.morphemes:
if m.out_of_vocab == 2: # IN_CUSTOM_DICT
print(m.text.content, m.tag, m.custom_dict_name)
신상밈 NNP trend
If out_of_vocab is IN_CUSTOM_DICT (value 2) and custom_dict_name is the domain you intended, the change has been applied.
If you don't see it right away, wait a moment
In environments with weak file system notifications (such as network mounts), a change may not show up immediately. In that case, the periodic check of up to 60 seconds will apply it, so wait a moment and analyze again. If it still does not change, check that the dictionary file was saved exactly in the watched directory.
Frequently asked questions
Q. Do I need to restart the server after changing the dictionary?
No. Bareun detects file changes in the dictionary directory and rereads them without downtime when a file changes. The new dictionary is applied without cutting off requests in progress.
Q. How quickly is a change applied?
When you change the dictionary through the API, it applies in that process as soon as the call is made. If several processes share the same directory, external file changes are also detected in real time and applied. Even if an event is missed or notifications are weak, the 60-second periodic check catches up, so the change is applied within one minute at most in every case.
Q. How do I confirm it was applied?
Analyze a sentence that contains the word you changed, and check that out_of_vocab is IN_CUSTOM_DICT and that custom_dict_name is the domain you intended. This is the most reliable way to verify.