Building and Running Your Service Natively
The next step in the binder development process is to build your binder and run it using your native Linux system.
NOTE:
This section assumes using thehelloworld-binding
example and completion of the previous steps in this “Building Microservices Natively” section.
Building the Service
Move to the cloned helloworld-binding
repository and build the service
using either of the following methods:
-
cd helloworld-binding mkdir build cd build cmake .. make
Running the Service
You use the Application Framework Binder Daemon (afb-binder
) to
bind one instance of an application or service to the rest of the system.
In this example, you are binding an instance of helloworld-binding
to the rest of the system:
afb-binder --workdir=./package --binding=lib/afb-helloworld-skeleton.so --port=3333 -vvv
The previous command starts afb-binder
and loads the afb-helloworld-skeleton.so
binding.
The daemon is now listening on port 3333 of the localhost
.
Testing the Service
Refer to the
Test Framework topic in the
“Developer guides” topic.
You can test your helloworld-binding
using the afm-test
tool.
Examine the generic example describing how to launch the tests suite here. This example can help you understand how to test your helloworld binding instance.
Troubleshooting
systemd and/or libmicrohttpd
If you encounter an error message similar to the following,
you need to make some changes to your cmake
file:
-- Checking for module 'libmicrohttpd>=0.9.60'
-- No package 'libmicrohttpd' found
CMake Error at /usr/share/cmake/Modules/FindPkgConfig.cmake:415 (message):
A required package was not found
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPkgConfig.cmake:593 (_pkg_check_modules_internal)
conf.d/app-templates/cmake/cmake.d/01-build_options.cmake:92 (PKG_CHECK_MODULES)
conf.d/app-templates/cmake/common.cmake:77 (include)
conf.d/cmake/config.cmake:184 (include)
CMakeLists.txt:3 (include)
Open the config.cmake
file located in helloworld-binding/conf.d/cmake/
directory
and add a hash character (i.e. #) to the beginning of the “libsystemd>=222”
and “libmicrohttpd>=0.9.60” strings.
Following is an example of the edits:
set (PKG_REQUIRED_LIST
json-c
#libsystemd>=222
afb-binding
#libmicrohttpd>=0.9.60
)
After making these changes, rebuild the service again as described in the “Building the Service” section previously on this page.