Sample Publisher Apps ===================== Publisher apps consists of the following: C++ Publisher ------------- The C++ publisher and server are supported in Ubuntu and Alpine operating systems or docker images. The C++ publisher runs in the independent containers ``ia_ubuntu_cpp_sample_pub`` and ``ia_alpine_cpp_sample_pub`` respectively. Go Publisher ------------ The Go publisher and server are supported in Ubuntu and Alpine operating systems or docker images. The Go publisher runs in the independent containers ``ia_ubuntu_go_sample_pub`` and ``ia_alpine_go_sample_pub`` respectively. Python Publisher ---------------- The Python publisher and server are supported only in Ubuntu operating systems or docker images. The Python publisher runs in the independent containers ``ia_ubuntu_python_sample_pub``. .. note:: The sample publisher container comprises of both the publisher and the server functionality. High-level Logical Flow for Sample Publisher Apps ------------------------------------------------- The high-level logical flow of a sample publisher app is as follows: #. Sample apps use the ConfigMgr(\ ``[WORK_DIR]/IEdgeInsights/common/libs/ConfigMgr/src/cfgmgr.c``\ ) APIs to construct the ``msgbus`` config from the ETCD. It fetches its private key and the allowed client's public keys. Then it creates the publisher object and starts publishing the sample data at a given topic (topic name: publish_test). #. The server contacts the ETCD service and fetches its private key and the allowed client's public keys. Then it creates a server object according to the given service name and waits for the client's request. Steps to Independently Build and Deploy Samples Publisher Service ----------------------------------------------------------------- .. note:: For running 2 or more microservices, we recommend users to try the use case-driven approach for building and deploying as mentioned at `Generate Consolidated Files for a Subset of Edge Insights for Industrial Services `_ Steps to Independently Build Samples Publisher Service ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ .. note:: When switching between independent deployment of the service with and without config manager agent service dependency, one would run into issues with ``docker-compose build`` w.r.t Certificates folder existence. As a workaround, run the command ``sudo rm -rf Certificates`` to proceed with ``docker-compose build``. To independently build Samples publisher service, complete the following steps: #. The downloaded source code should have a directory named Samples: Enter into the AppContext by selecting the ```` and ```` of your choice in the following command: .. code-block:: sh cd IEdgeInsights/Samples/publisher// .. **NOTE**\ : ```` can be either ``cpp``\ , ``go`` or ``python`` and ```` can be either ``alpine`` or ``ubuntu``. Ensure to select ```` as ``ubuntu``. If the ```` is ``python`` as the Python publisher and server are supported only in Ubuntu operating systems or docker images. #. Copy the IEdgeInsights/build/.env file using the following command in the current folder .. code-block:: sh cp ../../../../build/.env . .. **NOTE**\ : Update the HOST_IP and ETCD_HOST variables in the .env file with your system IP. .. code-block:: sh # Source the .env using the following command: set -a && source .env && set +a #. Independently build .. code-block:: sh docker-compose build Steps to Independently Deploy Samples Publisher Service ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ You can deploy the Samples publisher service in any of the following two ways: Deploy Samples Publisher Service without Config Manager Agent Dependency ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Run the following commands to deploy Samples publisher service without Config Manager Agent dependency: .. code-block:: sh # Enter the AppContext cd IEdgeInsights/Samples/publisher// .. Copy the IEdgeInsights/build/.env file using the following command in the current folder, if not already present. .. code-block:: sh cp ../../../../build/.env . **Note:** Ensure that ``docker ps`` is clean and ``docker network ls`` must not have EII bridge network. .. code-block:: Update .env file for the following: 1. HOST_IP and ETCD_HOST variables with your system IP. 2. `READ_CONFIG_FROM_FILE_ENV` value to `true` and `DEV_MODE` value to `true`. Source the .env using the following command: set -a && source .env && set +a .. code-block:: sh # Run the service docker-compose -f docker-compose.yml -f docker-compose-dev.override.yml up -d Deploy Samples Publisher Service with Config Manager Agent Dependency ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Run the following commands to deploy Samples publisher service with Config Manager Agent dependency: .. note:: Ensure that the Config Manager Agent image present in the system. If not, build the Config Manager Agent locally when independently deploying the service with Config Manager Agent dependency. .. code-block:: sh # Enter the AppContext cd IEdgeInsights/Samples/publisher// .. Copy the IEdgeInsights/build/.env file using the following command in the current folder, if not already present. .. code-block:: sh cp ../../../../build/.env . **Note:** Ensure that ``docker ps`` is clean and ``docker network ls`` doesn't have EII bridge networks. .. code-block:: Update .env file for following: 1. HOST_IP and ETCD_HOST variables with your system IP. 2. `READ_CONFIG_FROM_FILE_ENV` value is set to `false`. .. Copy the docker-compose.yml from IEdgeInsights/ConfigMgrAgent as docker-compose.override.yml. .. code-block:: sh cp ../../../../ConfigMgrAgent/docker-compose.yml docker-compose.override.yml .. Copy the builder.py with standalone mode changes from IEdgeInsights/build directory .. code-block:: sh cp ../../../../build/builder.py . Run the builder.py in standalone mode, this will generate eii_config.json and update docker-compose.override.yml .. code-block:: sh python3 builder.py -s true .. Build the service (This step is optional for building the service if not done in the ``Independently buildable`` step). .. code-block:: sh docker-compose build .. Run the service in PROD mode, ececute the following command: **NOTE**\ : Ensure to update ``DEV_MODE`` to ``false`` in .env while running in PROD mode and source the .env using the command ``set -a && source .env && set +a``. .. code-block:: sh docker-compose up -d .. Run the service in DEV mode, execute the following command: **NOTE**\ : Ensure to update ``DEV_MODE`` to ``true`` in .env while running in DEV mode and source the .env using the command ``set -a && source .env && set +a``. .. code-block:: sh docker-compose -f docker-compose.yml -f docker-compose-dev.override.yml -f docker-compose.override.yml up -d