feat: enable rest api in libstorage in debug builds

This commit is contained in:
E M 2026-02-10 20:44:24 +11:00
parent 3830ecc9e6
commit aad548566a
No known key found for this signature in database
2 changed files with 19 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:libstorage_DisableRestApi=0
else ifeq ($(DEBUG),0)
LIBSTORAGE_PARAMS := $(LIBSTORAGE_PARAMS) -d:libstorage_DisableRestApi=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 libstorage_DisableRestApi* {.booldefine.} = true
type NodeLifecycleMsgType* = enum
CREATE_NODE
START_NODE
@ -139,7 +141,10 @@ proc createStorage(
return err("Failed to create Storage: unable to get the private key.")
let pk = privateKey.get()
conf.apiBindAddress = string.none
when libstorage_DisableRestApi:
conf.apiBindAddress = string.none
else:
debug "Rest API is enabled!"
let server =
try: