(python)进程管理器
pman的Python项目详细描述
Overview
这个存储库证明了pman–一个流程管理器。
pman
最简单的是,pman管理进程,即由底层系统运行的程序或应用程序。通常,这些进程是命令行应用程序(即没有gui),通常根本不与用户真正交互。pman的主要目的是通过http为其他软件代理提供执行进程的能力。
最初,pman设计用于跟踪在本地系统上执行的简单进程。此外,pman还记录它已执行的进程的当前和历史状态,因此能够响应有关进程的查询。pman可以处理的一些查询是
- state:作业<;xyz>;是否仍在运行?
- result:job中的stdout(或stderr)是什么<;xyz>;?
- control:终止作业<;xyz>;
pman还在作业文件系统和作业状态中维护一个持久的人类可读/友好数据库。
但是,pman的当前版本可以使用基于容器的后端(swarm和openshift)来执行进程。在这些情况下,跟踪作业的内部数据库变得多余。未来版本的pman可能会降低本地/内部数据库跟踪的成本。
Installation
安装相对简单,我们建议使用python虚拟环境或docker。
Python Virtual Environment
在ubuntu上,安装python virtual environment creator
sudo apt install virtualenv virtualenvwrapper
然后,为您的虚拟环境创建一个目录,例如:
mkdir ~/python-envs
您可能需要将这两行代码添加到.bashrc文件中:
exportWORKON_HOME=~/python-envs source /usr/local/bin/virtualenvwrapper.sh
(注意,根据发行版的不同,virtualenvwrapper.sh路径可能是
/usr/share/virtualenvwrapper/virtualenvwrapper.sh
然后,您可以获得.bashrc源代码并创建一个新的python3虚拟环境:
source .bashrc mkvirtualenv --python=python3 python_env
激活或“输入”虚拟环境:
workon python_env
要停用虚拟环境:
deactivate
Using the ^{tt1}$ dock
不过,最简单的选择是使用fnndsc/pmandock。
docker pull fnndsc/pman
然后运行
docker run --name pman \ -v /home:/Users \ --rm -ti \ fnndsc/pman \ --rawmode 1 --http \ --port 5010\ --listeners 12
Usage
pman用法
有关pman的详细信息,请参见pman wiki page。
ARGS [--ip <IP>] The IP interface on which to listen. [--port <port>] The port on which to listen. Defaults to '5010'. [--protocol <protcol>] The protocol to interpret. Defaults to 'tcp'. [--rawmode] Internal zmq socket server mode. A value of '1' is usually used here. [--listeners <numberOfListenerThreads>] The number of internal threads to which requests are dispatched. [--http] Send return strings as HTTP formatted replies with content-type html. [--debugToFile] If specified, send debugging results to file. [--debugToFile <file>] In conjunction with --debugToFile, file which will receive debugging info. [--listenerSleep <time>] A small delay in the listener loop to prevent busy-wait. Default is 0.1 seconds. [--DBsavePeriod <time>] The periodicity in seconds for the internal DB save. [--enableTokenAuth] Enables token based authorization and can be configured to look for a .ini file or an openshift secret. [--tokenPath <tokenPath>] Specify the absolute path to the token in the file system. By default, this looks for the pfiohConfig.ini file in the current working directory. [-x|--desc] Provide an overview help page. [-y|--synopsis] Provide a synopsis help summary. [--version] Print internal version number and exit. [-v|--verbosity <level>] Set the verbosity level. "0" typically means no/minimal output. Allows for more fine tuned output control as opposed to '--quiet' that effectively silences everything. --container-env <env> The container env within which to run.
EXAMPLES
使用12个侦听器启动pman:
pman \\ --ip 127.0.0.1 \\ --port 5010\\ --rawmode 1\\ --http \\ --listeners 12\\ --verbosity 1