some_package.some_class.SomeClass.start_me
or some_package.some_script.main_function
Everything else is handled by launch.py [1].
launch.py is a set of friendly Python tools to install Virtual Environment, start, stop your application. In addition it gives you a single interface to test and analyze your code; provides configuration management.
In this post we will outline two features: installation and daemonization.
Installation. It's simple. launch.py will create a Virtual Environment for you and make sure that your application is executed within it. What you need to do is to download all of the required libraries for your application and place them in folder:
launch.py/vendor
Order of the libraries installation is defined by script:
launch.py/scripts/install_virtualenv.sh
Once this step is complete just run ./launch.py -i to install Virtual Environment along with all of required libraries.
launch.py is also there to help with the application start and stop. There are two modes to run your application:
- daemonized
the application is started in a separate process - interactive
the application is executed in the same command-line terminal where you have called launch.py and uses shared stdin, stdout and stderr to interact with the user
- Write the actual code
List of the following assumptions is in place:
- starter method or function has signature starter_name(*args)- classes implement __init__(self, process_name) - Register your fully specified function/method name in launch.py/system/process_context.py as follows:
PROCESS_CONTEXT = { ... 'YOUR_PROCESS_NAME': _create_context_entry( process_name='YOUR_PROCESS_NAME', classname='workers.some_script.main', token='YOUR_PROCESS_NAME', time_qualifier=''), ...
Should you wish to instantiate a class instance and start its method - simply define the class name:classname='workers.some_module.YourPythonClass.starter_name'
- ./launch.py --run --app YOUR_PROCESS_NAME will start your class' or script's starter method/function in a separate process (daemonized mode)
- Add --interactive to the command above and run it in an interactive mode
Cheers!
https://github.com/mushkevych/launch.py
[2] launch.py WIKI
https://github.com/mushkevych/launch.py/wiki
No comments:
Post a Comment