|
|
|
|
|
|
|
|
<!DOCTYPE html>
|
|
|
<!--[if IE 8]><html class="no-js lt-ie9" lang="zh-CN" > <![endif]-->
|
|
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="zh-CN" > <!--<![endif]-->
|
|
|
<head>
|
|
|
<meta charset="utf-8">
|
|
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
|
<title>Arthas异步调用 — Arthas 3.0.5-SNAPSHOT 文档</title>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="shortcut icon" href="_static/favicon.ico"/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
|
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
|
<link rel="stylesheet" href="_static/overrides.css" type="text/css" />
|
|
|
<link rel="index" title="索引" href="genindex.html" />
|
|
|
<link rel="search" title="搜索" href="search.html" />
|
|
|
<link rel="next" title="执行结果存日志" href="save-log.html" />
|
|
|
<link rel="prev" title="Web Console" href="web-console.html" />
|
|
|
<script src="_static/center_page.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="_static/js/modernizr.min.js"></script>
|
|
|
|
|
|
</head>
|
|
|
|
|
|
<body class="wy-body-for-nav">
|
|
|
|
|
|
|
|
|
<div class="wy-grid-for-nav">
|
|
|
|
|
|
|
|
|
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
|
|
|
<div class="wy-side-scroll">
|
|
|
<div class="wy-side-nav-search">
|
|
|
|
|
|
|
|
|
|
|
|
<a href="index.html" class="icon icon-home"> Arthas
|
|
|
|
|
|
|
|
|
|
|
|
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="version">
|
|
|
3.0.5-SNAPSHOT
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="search">
|
|
|
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
|
|
|
<input type="text" name="q" placeholder="Search docs" />
|
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
|
<input type="hidden" name="area" value="default" />
|
|
|
</form>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul class="current">
|
|
|
<li class="toctree-l1"><a class="reference external" href="https://alibaba.github.io/arthas/en/">English Docs</a></li>
|
|
|
<li class="toctree-l1"><a class="reference internal" href="install-detail.html">安装</a></li>
|
|
|
<li class="toctree-l1"><a class="reference internal" href="quick-start.html">快速入门</a></li>
|
|
|
<li class="toctree-l1 current"><a class="reference internal" href="advanced-use.html">进阶使用</a><ul class="current">
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#">基础命令</a></li>
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#jvm">jvm相关</a></li>
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#class-classloader">class/classloader相关</a></li>
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#monitor-watch-trace">monitor/watch/trace相关</a></li>
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#options">options</a></li>
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#">管道</a></li>
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#">后台异步任务</a></li>
|
|
|
<li class="toctree-l2"><a class="reference internal" href="advanced-use.html#web-console">Web Console</a></li>
|
|
|
<li class="toctree-l2 current"><a class="reference internal" href="advanced-use.html#">其他特性</a><ul class="current">
|
|
|
<li class="toctree-l3 current"><a class="current reference internal" href="#">异步命令支持</a><ul>
|
|
|
<li class="toctree-l4"><a class="reference internal" href="#">1. 使用&在后台执行任务</a></li>
|
|
|
<li class="toctree-l4"><a class="reference internal" href="#jobs">2. 通过jobs查看任务</a></li>
|
|
|
<li class="toctree-l4"><a class="reference internal" href="#">3. 任务暂停和取消</a></li>
|
|
|
<li class="toctree-l4"><a class="reference internal" href="#fgbg">4. fg、bg命令,将命令转到前台、后台继续执行</a></li>
|
|
|
<li class="toctree-l4"><a class="reference internal" href="#">5. 任务输出重定向</a></li>
|
|
|
<li class="toctree-l4"><a class="reference internal" href="#">6. 停止命令</a></li>
|
|
|
<li class="toctree-l4"><a class="reference internal" href="#">7. 其他</a></li>
|
|
|
</ul>
|
|
|
</li>
|
|
|
<li class="toctree-l3"><a class="reference internal" href="save-log.html">执行结果存日志</a></li>
|
|
|
<li class="toctree-l3"><a class="reference internal" href="batch-support.html">批处理的支持</a></li>
|
|
|
<li class="toctree-l3"><a class="reference external" href="https://github.com/alibaba/arthas/issues/11">ognl表达式的用法说明</a></li>
|
|
|
</ul>
|
|
|
</li>
|
|
|
</ul>
|
|
|
</li>
|
|
|
<li class="toctree-l1"><a class="reference internal" href="commands.html">命令列表</a></li>
|
|
|
<li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/issues?q=label%3Auser-case">用户案例</a></li>
|
|
|
<li class="toctree-l1"><a class="reference internal" href="release-notes.html">Release Notes</a></li>
|
|
|
<li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/issues?q=label%3Aquestion-answered">Questions and answers</a></li>
|
|
|
<li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas">Fork me at GitHub</a></li>
|
|
|
<li class="toctree-l1"><a class="reference external" href="https://github.com/alibaba/arthas/blob/master/CONTRIBUTING.md">参与贡献</a></li>
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
</nav>
|
|
|
|
|
|
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
|
|
|
|
|
|
|
|
|
<nav class="wy-nav-top" aria-label="top navigation">
|
|
|
|
|
|
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
|
|
|
<a href="index.html">Arthas</a>
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
<div class="wy-nav-content">
|
|
|
|
|
|
<div class="rst-content">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div role="navigation" aria-label="breadcrumbs navigation">
|
|
|
|
|
|
<ul class="wy-breadcrumbs">
|
|
|
|
|
|
<li><a href="index.html">Docs</a> »</li>
|
|
|
|
|
|
<li><a href="advanced-use.html">进阶使用</a> »</li>
|
|
|
|
|
|
<li>Arthas异步调用</li>
|
|
|
|
|
|
|
|
|
<li class="wy-breadcrumbs-aside">
|
|
|
|
|
|
|
|
|
|
|
|
<a href="https://github.com/alibaba/arthas/blob/master/site/src/site/sphinx/async.md" class="fa fa-github"> Edit on GitHub</a>
|
|
|
|
|
|
|
|
|
|
|
|
</li>
|
|
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
<hr/>
|
|
|
</div>
|
|
|
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
|
|
|
<div itemprop="articleBody">
|
|
|
|
|
|
<div class="section" id="arthas">
|
|
|
<span id="arthas"></span><h1>Arthas异步调用<a class="headerlink" href="#arthas" title="永久链接至标题">¶</a></h1>
|
|
|
<p>arthas中的异步调用,使用了仿linux系统任务相关的命令。<a class="reference external" href="https://ehlxr.me/2017/01/18/Linux-%E4%B8%AD-fg%E3%80%81bg%E3%80%81jobs%E3%80%81-%E6%8C%87%E4%BB%A4/">linux任务相关介绍</a>。</p>
|
|
|
<div class="section" id="">
|
|
|
<span id="id1"></span><h2>1. 使用&在后台执行任务<a class="headerlink" href="#" title="永久链接至标题">¶</a></h2>
|
|
|
<p>比如希望执行后台执行trace命令,那么调用下面命令</p>
|
|
|
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>trace Test t <span class="p">&</span>
|
|
|
</pre></div>
|
|
|
</div>
|
|
|
<p>这时命令在后台执行,可以在console中继续执行其他命令。</p>
|
|
|
</div>
|
|
|
<div class="section" id="jobs">
|
|
|
<span id="jobs"></span><h2>2. 通过jobs查看任务<a class="headerlink" href="#jobs" title="永久链接至标题">¶</a></h2>
|
|
|
<p>如果希望查看当前有哪些arthas任务在执行,可以执行jobs命令,执行结果如下</p>
|
|
|
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ <span class="nb">jobs</span>
|
|
|
<span class="o">[</span><span class="m">10</span><span class="o">]</span>*
|
|
|
Stopped watch com.taobao.container.Test <span class="nb">test</span> <span class="s2">"params[0].{? #this.name == null }"</span> -x <span class="m">2</span>
|
|
|
execution count : <span class="m">19</span>
|
|
|
start <span class="nb">time</span> : Fri Sep <span class="m">22</span> <span class="m">09</span>:59:55 CST <span class="m">2017</span>
|
|
|
timeout date : Sat Sep <span class="m">23</span> <span class="m">09</span>:59:55 CST <span class="m">2017</span>
|
|
|
session : 3648e874-5e69-473f-9eed-7f89660b079b <span class="o">(</span>current<span class="o">)</span>
|
|
|
</pre></div>
|
|
|
</div>
|
|
|
<p>可以看到目前有一个后台任务在执行。</p>
|
|
|
<ul class="simple">
|
|
|
<li>job id是10, <code class="docutils literal notranslate"><span class="pre">*</span></code> 表示此job是当前session创建</li>
|
|
|
<li>状态是Stopped</li>
|
|
|
<li>execution count是执行次数,从启动开始已经执行了19次</li>
|
|
|
<li>timeout date是超时的时间,到这个时间,任务将会自动超时退出</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
<div class="section" id="">
|
|
|
<span id="id2"></span><h2>3. 任务暂停和取消<a class="headerlink" href="#" title="永久链接至标题">¶</a></h2>
|
|
|
<p>当任务正在前台执行,比如直接调用命令<code class="docutils literal notranslate"><span class="pre">trace</span> <span class="pre">Test</span> <span class="pre">t</span></code>或者调用后台执行命令<code class="docutils literal notranslate"><span class="pre">trace</span> <span class="pre">Test</span> <span class="pre">t</span> <span class="pre">&</span></code>后又通过<code class="docutils literal notranslate"><span class="pre">fg</span></code>命令将任务转到前台。这时console中无法继续执行命令,但是可以接收并处理以下事件:</p>
|
|
|
<ul class="simple">
|
|
|
<li>‘ctrl + z’:将任务暂停。通过<code class="docutils literal notranslate"><span class="pre">jbos</span></code>查看任务状态将会变为Stopped,通过<code class="docutils literal notranslate"><span class="pre">bg</span> <span class="pre"><job-id></span></code>或者<code class="docutils literal notranslate"><span class="pre">fg</span> <span class="pre"><job-id></span></code>可让任务重新开始执行</li>
|
|
|
<li>‘ctrl + c’:停止任务</li>
|
|
|
<li>‘ctrl + d’:按照linux语义应当是退出终端,目前arthas中是空实现,不处理</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
<div class="section" id="fgbg">
|
|
|
<span id="fgbg"></span><h2>4. fg、bg命令,将命令转到前台、后台继续执行<a class="headerlink" href="#fgbg" title="永久链接至标题">¶</a></h2>
|
|
|
<ul class="simple">
|
|
|
<li>任务在后台执行或者暂停状态(‘ctrl + z’暂停任务)时,执行fg <job-id>将可以把对应的任务转到前台继续执行。在前台执行时,无法在console中执行其他命令</li>
|
|
|
<li>当任务处于暂停状态时(‘ctrl + z’暂停任务),执行bg <job-id>将可以把对应的任务在后台继续执行</li>
|
|
|
<li>非当前session创建的job,只能由当前session fg到前台执行</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
<div class="section" id="">
|
|
|
<span id="id3"></span><h2>5. 任务输出重定向<a class="headerlink" href="#" title="永久链接至标题">¶</a></h2>
|
|
|
<p>可通过<code class="docutils literal notranslate"><span class="pre">></span></code>或者<code class="docutils literal notranslate"><span class="pre">>></span></code>将任务输出结果输出到指定的文件中,可以和<code class="docutils literal notranslate"><span class="pre">&</span></code>一起使用,实现arthas命令的异步调用。比如:</p>
|
|
|
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t >> test.out <span class="p">&</span>
|
|
|
</pre></div>
|
|
|
</div>
|
|
|
<p>这时trace命令会在后台执行,并且把结果输出到~/logs/arthas-cache/test.out。可继续执行其他命令。并可查看文件中的命令执行结果。</p>
|
|
|
<p>当远程调用时,可能无法确定机器文件路径,arthas同时支持了自动重定向到缓存路径。使用方法如下:</p>
|
|
|
<div class="highlight-sh notranslate"><div class="highlight"><pre><span></span>$ trace Test t >> <span class="p">&</span>
|
|
|
job id : <span class="m">2</span>
|
|
|
cache location : /Users/gehui/logs/arthas-cache/28198/2
|
|
|
</pre></div>
|
|
|
</div>
|
|
|
<p>可以看到并没有指定重定向文件位置,arthas自动重定向到缓存中了,执行命令后会输出job id和cache location。cache location就是重定向文件的路径,在系统logs目录下,路径包括pid和job id,避免和其他任务冲突。命令输出结果到<code class="docutils literal notranslate"><span class="pre">/Users/gehui/logs/arthas-cache/28198/2</span></code>中,job id为2。</p>
|
|
|
</div>
|
|
|
<div class="section" id="">
|
|
|
<span id="id4"></span><h2>6. 停止命令<a class="headerlink" href="#" title="永久链接至标题">¶</a></h2>
|
|
|
<p>异步执行的命令,如果希望停止,可执行kill <job-id></p>
|
|
|
</div>
|
|
|
<div class="section" id="">
|
|
|
<span id="id5"></span><h2>7. 其他<a class="headerlink" href="#" title="永久链接至标题">¶</a></h2>
|
|
|
<ul class="simple">
|
|
|
<li>最多同时支持8个命令使用重定向将结果写日志</li>
|
|
|
<li>请勿同时开启过多的后台异步命令,以免对目标JVM性能造成影响</li>
|
|
|
</ul>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
<footer>
|
|
|
|
|
|
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
|
|
|
|
|
|
<a href="save-log.html" class="btn btn-neutral float-right" title="执行结果存日志" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
|
|
|
|
|
|
|
|
|
<a href="web-console.html" class="btn btn-neutral" title="Web Console" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
<hr/>
|
|
|
|
|
|
<div role="contentinfo">
|
|
|
<p>
|
|
|
© Copyright 2018, Alibaba Middleware Group, and contributors.
|
|
|
|
|
|
</p>
|
|
|
</div>
|
|
|
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
|
|
|
|
|
|
</footer>
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
</section>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
var DOCUMENTATION_OPTIONS = {
|
|
|
URL_ROOT:'./',
|
|
|
VERSION:'3.0.5-SNAPSHOT',
|
|
|
LANGUAGE:'zh_CN',
|
|
|
COLLAPSE_INDEX:false,
|
|
|
FILE_SUFFIX:'.html',
|
|
|
HAS_SOURCE: true,
|
|
|
SOURCELINK_SUFFIX: '.txt'
|
|
|
};
|
|
|
</script>
|
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
|
<script type="text/javascript" src="_static/translations.js"></script>
|
|
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript" src="_static/js/theme.js"></script>
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
jQuery(function () {
|
|
|
SphinxRtdTheme.Navigation.enable(true);
|
|
|
});
|
|
|
</script>
|
|
|
<div class="github-fork-ribbon-wrapper right">
|
|
|
<div class="github-fork-ribbon">
|
|
|
<a href="https://github.com/alibaba/arthas">Fork me at GitHub</a>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript" src="_static/add_badges.js"></script>
|
|
|
|
|
|
<script>
|
|
|
var _hmt = _hmt || [];
|
|
|
(function() {
|
|
|
var hm = document.createElement("script");
|
|
|
hm.src = "https://hm.baidu.com/hm.js?d5c5e25b100f0eb51a4c35c8a86ea9b4";
|
|
|
var s = document.getElementsByTagName("script")[0];
|
|
|
s.parentNode.insertBefore(hm, s);
|
|
|
})();
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
</html> |