How to Configure the maximal Number of Open File Handles¶
The maximum number of open file/socket handles is by default limited to 1024. This is not enough for some apps (e.g. connectivity apps or databases).
The actual settings can be shown with:
Maximum file handles:
Allocated, allocated but unused, maximum number of file handles:
For a lot of apps the number of 1024 maximal opened file handles is sufficient.
If a larger number of opened file handles is required this can be done with the command
ulimit, for example:
ulimit -n 16384
Your app should run this command in the startup phase of your app.
Therefor we recommend to:
- Create a script in a sub folder e.g. ulimit-snap/ of your project.
- And to add into your snapcraft.yaml file a daemon entry to call this script at startup.
#!/bin/sh ulimit -n 16384
parts: ulimit-script: plugin: dump source: ./ulimit-snap apps: ulimit: daemon: simple command: increase-ulimit.sh
Complete Example Snap¶
In this SDK an complete example project creating a demo snap is stored under samples-sh/ulimit-snap.
The sample project folder also contains a README.md file with further informations.