diff --git a/Makefile b/Makefile index bb68e931..b4fe4883 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/library/storage_thread_requests/requests/node_lifecycle_request.nim b/library/storage_thread_requests/requests/node_lifecycle_request.nim index c04bd5bf..491847aa 100644 --- a/library/storage_thread_requests/requests/node_lifecycle_request.nim +++ b/library/storage_thread_requests/requests/node_lifecycle_request.nim @@ -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: