By default, you have a single circuit framework where every Resilient extension package you install uses the same configuration file.
You may need to run multiple circuits for your environment. Reasons could include:
- Isolation. You may wish to keep one or more extensions separate for troubleshooting and logging purposes. With a single circuit, all Resilient extensions reference the same app.config file and log to a single log file.
- Ability to set up development and production environments on the same integration server.
- Performance. Upon startup, Resilient Circuits loads each extension one by one. It would be quicker to have each extension loaded by its own circuit, more importantly on its own system process.
- MSSP. If you have a Resilient platform with the MSSP add-on, you may wish to have a single integration server that can run extensions on multiple organizations.
A common method to create multiple circuits on a single integration server is to use virtualenv to create isolated Python environments. Each virtual environment includes its own Python runtime, pip, and libraries, including the Resilient and Resilient Circuits libraries. Also, each environment needs to specify an alternate location for the "resilient_circuits_lockfile" file in the "APP_LOCK_FILE" environment variable to prevent multiple copies of the application from running at once. The lock file config option cannot be specified in the app.config file.
The following procedure is an example of using virtualenv to create isolated Python environments.
- Install virtualevn:
pip install virtualenv
- Create a development environment:
mkdir ~/dev
- Create a virtualenv project:
cd ~/dev
virtualenv dev
cd bin
source ./activate
- Install all the python libraries. To install Resilient Circuits:
pip install resilient-circuits
- Add the following lines into the app.py to set the lock file variable. In the following example, it is located at ~/dev/dev/lib/python2.7/site-packages/resilient_circuits/app.py. Optionally, you can specify the log file location and app config file location.
os.environ["APP_CONFIG_FILE"] = "/root/.resilient/app.config.dev"
os.environ["APP_LOCK_FILE"] = "/root/.resilient/resilient_circuits_lockfile_dev"
os.environ["APP_LOG_DIR"] = "/root/.resilient/app.log.dev"
APP_LOG_DIR = os.environ.get("APP_LOG_DIR", "logs")
application = none
logging_initialized - False
class AppArgumentParser(keyring_arguments.ArgumentParser)
Using the previous example, you would run Resilient Circuits from: ~/dev/dev/lib/python2.7. And the pip you use is located at ~/dev/dev/bin/pip.
To run Resilient Circuits, you add the path to the configuration file. For example:
resilient-circuits config -c /path/to/<filename>.config
Alternately, instead of modifying app.py to configure the lock file as described in step 5, you can perform the following:
- Create a file called run.py in each virtualenv folder. For example:
- Specify the lock file in the script. You can also specify the log_file or app config file in the script; otherwise, the run.py uses any file named run.py from the same folder of the run.py script, and generates a log file in the same folder as well.
- Instead of using the resilient-circuits run command, you start integration by invoking "python run.py". The python has to be the python runtime from your virtualenv.
------------------------------
Bob Govoni
------------------------------