feat(libstorage): enable rest api in libstorage in debug builds (#1406)

This commit is contained in:
Eric 2026-02-11 19:25:53 +11:00 committed by GitHub
parent 3830ecc9e6
commit d02f44ffd6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 5 deletions

View File

@ -64,6 +64,15 @@ else
endif
export CXXFLAGS
LIBSTORAGE_PARAMS :=
# By default, libstorage disables the restapi. To build libstorage with the rest
# api enabled for remote debugging, use `make DEBUG=1 libstorage`
ifeq ($(DEBUG),1)
LIBSTORAGE_PARAMS := $(LIBSTORAGE_PARAMS) -d:LibstorageDisableRestApi=0
else ifeq ($(DEBUG),0)
LIBSTORAGE_PARAMS := $(LIBSTORAGE_PARAMS) -d:LibstorageDisableRestApi=1
endif
# we don't want an error here, so we can handle things later, in the ".DEFAULT" target
-include $(BUILD_SYSTEM_DIR)/makefiles/variables.mk
@ -240,15 +249,15 @@ libstorage:
ifeq ($(STATIC), 1)
echo -e $(BUILD_MSG) "build/$@.a" && \
$(ENV_SCRIPT) nim libstorageStatic $(NIM_PARAMS) codex.nims
$(ENV_SCRIPT) nim libstorageStatic $(NIM_PARAMS) $(LIBSTORAGE_PARAMS) codex.nims
else ifeq ($(detected_OS),Windows)
echo -e $(BUILD_MSG) "build/$@.dll" && \
$(ENV_SCRIPT) nim libstorageDynamic $(NIM_PARAMS) codex.nims
$(ENV_SCRIPT) nim libstorageDynamic $(NIM_PARAMS) $(LIBSTORAGE_PARAMS) codex.nims
else ifeq ($(detected_OS),macOS)
echo -e $(BUILD_MSG) "build/$@.dylib" && \
$(ENV_SCRIPT) nim libstorageDynamic $(NIM_PARAMS) codex.nims
$(ENV_SCRIPT) nim libstorageDynamic $(NIM_PARAMS) $(LIBSTORAGE_PARAMS) codex.nims
else
echo -e $(BUILD_MSG) "build/$@.so" && \
$(ENV_SCRIPT) nim libstorageDynamic $(NIM_PARAMS) codex.nims
$(ENV_SCRIPT) nim libstorageDynamic $(NIM_PARAMS) $(LIBSTORAGE_PARAMS) codex.nims
endif
endif # "variables.mk" was not included

View File

@ -27,6 +27,8 @@ from ../../../codex/codex import CodexServer, new, start, stop, close
logScope:
topics = "libstorage libstoragelifecycle"
const LibstorageDisableRestApi* {.booldefine.} = true
type NodeLifecycleMsgType* = enum
CREATE_NODE
START_NODE
@ -139,7 +141,11 @@ proc createStorage(
return err("Failed to create Storage: unable to get the private key.")
let pk = privateKey.get()
conf.apiBindAddress = string.none
when LibstorageDisableRestApi:
conf.apiBindAddress = string.none
debug "Rest API is disabled!"
else:
debug "Rest API is enabled!"
let server =
try: