Running the C Device Manager in a Production Environment
To run the device manager in a production environment, you may want to change the device manager behavior.
When you include the Device Cloud agent components in a VxWorks 7 image, the device manager is configured to run in a production environment. Therefore, most of the steps in this section do not apply to VxWorks 7. For more information, see Device Cloud Quick Start for VxWorks 7. If you want to change the device manager code, you should create a new thing definition and application for your device manager in Device Cloud.
By default, the C agent uses the Linux system directories for configuration and run-time files. However, you may want to configure the device manager to run as a service to start it when the device starts and automatically restart it if it fails.
You need the following:
-
the C agent built and installed in a system directory
-
the device manager connection configuration file you generated (see Generating a Connection Configuration File for a C Application)
-
a new thing definition and application for your device manager defined in Device Cloud
-
Copy the /etc/iot/iot.cfg.example
file to /etc/iot/iot.cfg and change the values as
needed.
- Ensure that the device manager connection configuration file, iot-connect.cfg is located in the /etc/iot directory.
- Create a user, for example device_cloud, under which to run the device manager program.
- To add the user to the sudoers list, create a file with the file name that matches the name of the user you created, add commands as required, and store the file in the /etc/sudoers.d directory.
- To configure the device manager to start when the device starts, use the appropriate service control method for your operating system.
-
Do one of the following to run the device manager:
-
To run the device manager as a service, start the service.
-
Run the device manager from the command line as the user you created.
$ iot-device-manager
-
When the device manager runs, the agent searches the /var/lib/iot directory for the device_id file and the /etc/iot directory for the iot-connect.cfg and iot.cfg files. The device manager appears as a thing with the thing key deviceId-device-manager on the Things page on the Management Portal.