Skip to content
Xing Yi edited this page Nov 6, 2023 · 5 revisions

Deploying to a resource-limited environment

SilverDict does not require much memory/CPU to run (91.3 MiB with 40 dictionaries and three morphology dictionaries, Python 3.11), but there are some techniques to improve performance and reduce memory usage in a resource-limited environment like a router or a VPS.

Steps

  1. Rename your existing SilverDict directories (~/.silverdict and ~/.cache/SilverDict) to something else, e.g. .silverdict.old.
  2. Restart the server.
  3. Change the running mode to preparation in ~/.silverdict/preferences.yaml. This tells SilverDict to extract all resource files in advance.
  4. Put all dictionaries you'd use into ~/.silverdict/source.
  5. Restart the server to apply the change in preferences.
  6. Run curl https://localhost:2628/api/management/scan to index the dictionaries, or do it in the web UI.
  7. Run curl https://localhost:2628/api/management/create_ngram_table to create the ngram index, or do it in the web UI, if you want to use the ngram search (both-sides expansion).
  8. Change .silverdict/preferences.yaml to your liking.
  9. Change the filenames in ~/.silverdict/dictionaries.yaml to reflect their paths on the target machine (user name, etc. may be different).
  10. Fix any symbolic links in ~/.silverdict/cache/SilverDict.
  11. Move ~/.silverdict and ~/.cache/SilverDict to the target machine; it is recommended to first tar them.
  12. In the target machine, set the running mode to server in .silverdict/preferences.yaml.
  13. Start the server with systemd. You can find a sample unit file in the GitHub repo. It is not recommended to run the server as the root user.

Notes

  • MDict dictionaries use several times more memory than other formats.
  • HTML-formatted StarDict dictionaries are the best in terms of performance.
  • Hunspell dictionaries use a large amount of memory, so be careful when using them, and only use them for languages you need.
Clone this wiki locally