Skip to content

Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.

TypeScript

fix(admin): disk info mount and stability

Jake Turner6a9ede177633
diff --git a/admin/app/services/system_service.ts b/admin/app/services/system_service.ts
index 517a4bc8..08fddf25 100644
--- a/admin/app/services/system_service.ts
+++ b/admin/app/services/system_service.ts
@@ -129,18 +129,25 @@ export class SystemService {
si.time(),
])
- const diskInfoRawString = await getFile(
- path.join(process.cwd(), SystemService.diskInfoFile),
- 'string'
- )
+ let diskInfo: NomadDiskInfoRaw | undefined
+ let disk: NomadDiskInfo[] = []
- const diskInfo = (
- diskInfoRawString
- ? JSON.parse(diskInfoRawString.toString())
- : { diskLayout: { blockdevices: [] }, fsSize: [] }
- ) as NomadDiskInfoRaw
+ try {
+ const diskInfoRawString = await getFile(
+ path.join(process.cwd(), SystemService.diskInfoFile),
+ 'string'
+ )
+
+ diskInfo = (
+ diskInfoRawString
+ ? JSON.parse(diskInfoRawString.toString())
+ : { diskLayout: { blockdevices: [] }, fsSize: [] }
+ ) as NomadDiskInfoRaw
- const disk = this.calculateDiskUsage(diskInfo)
+ disk = this.calculateDiskUsage(diskInfo)
+ } catch (error) {
+ logger.error('Error reading disk info file:', error)
+ }
return {
cpu,
@@ -164,7 +171,7 @@ export class SystemService {
*/
private async _syncContainersWithDatabase() {
try {
- const allServices = await Service.all();
+ const allServices = await Service.all()
const serviceStatusList = await this.dockerService.getServicesStatus()
for (const service of allServices) {
@@ -189,7 +196,6 @@ export class SystemService {
}
}
}
-
} catch (error) {
logger.error('Error syncing containers with database:', error)
}
diff --git a/install/install_nomad.sh b/install/install_nomad.sh
index dc18a301..5b86f4bf 100644
--- a/install/install_nomad.sh
+++ b/install/install_nomad.sh
@@ -237,6 +237,12 @@ create_nomad_directory(){
sudo touch "${NOMAD_DIR}/storage/logs/admin.log"
}
+create_disk_info_file() {
+ # Disk info file MUST be created before the admin container starts.
+ # Otherwise, Docker will assume we meant to mount a directory and will create an empty directory at the mount point
+ echo '{}' > /tmp/nomad-disk-info.json
+}
+
download_management_compose_file() {
local compose_file_path="${NOMAD_DIR}/compose.yml"