Skip to content

Commit

Permalink
Add RAM availability to configuration and settings (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephdl authored Jan 8, 2025
1 parent 95eca68 commit c8c9e6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 11 additions & 1 deletion imageroot/actions/get-defaults/20readconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,20 @@ for key in agent.list_service_providers(rdb,'xmpp','tcp'):
}
ejabberd.append(obj)

# determine the amount of RAM available on the system
try:
with open('/proc/meminfo', 'r') as f:
for line in f:
if line.startswith('MemTotal:'):
ram_mb = int(line.split()[1]) // 1024 # Convert kB to MB
except Exception:
ram_mb = 4096

config={
"mail_modules_id": modules,
"ejabberd_modules_id": ejabberd,
"accepted_timezone_list": list_of_timezone_widget
"accepted_timezone_list": list_of_timezone_widget,
"ram_mb": ram_mb,
}

json.dump(config, fp=sys.stdout)
6 changes: 4 additions & 2 deletions ui/src/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
v-model="webapp.min_memory"
:label="$t('settings.min_webapp_memory')"
min="256"
max="4096"
:max="ram_mb"
step="1"
stepMultiplier="1023"
minLabel=""
Expand All @@ -230,7 +230,7 @@
v-model="webapp.max_memory"
:label="$t('settings.max_webapp_memory')"
min="256"
max="4096"
:max="ram_mb"
step="1"
stepMultiplier="1023"
minLabel=""
Expand Down Expand Up @@ -430,6 +430,7 @@ export default {
ejabberd_domain: "",
ejabberd_modules_id: [],
accepted_timezone_list: [],
ram_mb: "4096",
locale: "",
timezone: "",
webapp: {
Expand Down Expand Up @@ -556,6 +557,7 @@ export default {
value: "-",
});
this.accepted_timezone_list = config.accepted_timezone_list;
this.ram_mb = String(config.ram_mb);
this.getConfiguration();
this.loading.getDefaults = false;
},
Expand Down

0 comments on commit c8c9e6c

Please sign in to comment.