Non-containerized applications can be run with Deepfactor using the CLI, dfctl. This document will outline several common ways of using dfctl to observe non-containerized applications. Typically, you would use the steps detailed in this document when you want to observe an application that is launched via a script or executable.
Prerequisites #
In order to run your applications, you will need to fulfil the following prerequisites
- Export your Deepfactor run token. You will be able to retrieve this by logging into your account on the Deepfactor portal and clicking on Start button
- Install dfctl using the following command
curl https://repo.deepfactor.io/install-dfctl.sh | sh --
Simple scenarios using dfctl run #
You can use dfctl run to run standard executables using a single command
dfctl run -a appname -c componentname –cmd /usr/bin/myprogram
You can use dfctl run to run standard “startup-style” scripts similarly:
dfctl run -a appname -c componentname –cmd /usr/bin/startup.sh
Working with programs launched with sudo #
Scenarios involving sudo launching a single program can typically be done as follows:
Without Deepfactor:
sudo /usr/bin/myprogram
With Deepfactor:
sudo -E dfctl run -a app -c component –cmd /usr/bin/myprogram
In the above example, dfctl will be launched as root via sudo and will in turn launch /usr/bin/myprogram with Deepfactor. Note the inclusion of the -E sudo command line parameter to ensure that the caller’s environment variables are available to dfctl.
Working with scripts that contain embedded sudo #
Sometimes, you may have an application startup script that itself uses sudo internally to launch various application components as root. In this scenario, the simplest option is to run the script itself via sudo dfctl:
sudo -E dfctl run -a app -c component –cmd /usr/bin/startup.sh
In this example, even if startup.sh contains lines which themselves use sudo to launch other programs, since no privilege escalation is being performed by the “inner” sudo, Deepfactor will work properly. Note that the -E option must be used in the command above to preserve the LD_PRELOAD environment variable and the user running the sudo command must have permission to inherit environment variables (set in /etc/sudoers). Also note that any embedded sudo lines in the startup script must be modified to include the -E option.
Working with shell builtins
If your application’s launch requires setting an environment variable and is currently invoked using something like this:
FOO=BAR /usr/bin/myprogram
… you can launch this application using Deepfactor by creating a launch script as follows:
#!/bin/sh FOO=BAR /usr/bin/myprogram
… and then launching that script using dfctl run:
dfctl run -a app -c component –cmd my_new_launcher.sh