This commit is contained in:
virusdefender 2016-10-10 20:08:23 +08:00
parent cb37b94aa0
commit b17af2e2e7
2 changed files with 0 additions and 658 deletions

View File

@ -1,239 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="../../../img/favicon.ico">
<title>部署 - Online Judge Docs</title>
<link href="../../../css/bootstrap-custom.min.css" rel="stylesheet">
<link href="../../../css/font-awesome-4.0.3.css" rel="stylesheet">
<link rel="stylesheet" href="../../../css/highlight.css">
<link href="../../../css/base.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Main title -->
<a class="navbar-brand" href="../../..">Online Judge Docs</a>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li >
<a href="../../..">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Judger <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="../../../Judger/">index</a>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">English</a>
<ul class="dropdown-menu">
<li >
<a href="../../../Judger/English/">API</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">JudgeServer <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="../../">index</a>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">English</a>
<ul class="dropdown-menu">
<li >
<a href="../../English/">API</a>
</li>
<li >
<a href="../../English/deploy/">Deploy</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">中文</a>
<ul class="dropdown-menu">
<li >
<a href="../">API</a>
</li>
<li class="active">
<a href="./">部署</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<!-- Search, Navigation and Repo links -->
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
<li >
<a rel="next" href="../">
<i class="fa fa-arrow-left"></i> Previous
</a>
</li>
<li class="disabled">
<a rel="prev" >
Next <i class="fa fa-arrow-right"></i>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
<ul class="nav bs-sidenav">
<li class="main active"><a href="#link">同主机link场景</a></li>
<li class="main "><a href="#_1">跨主机场景</a></li>
</ul>
</div></div>
<div class="col-md-9" role="main">
<h1 id="link">同主机link场景</h1>
<p>oj_web_server和judge_server在同一台服务器上而且judge_server中link oj_web_server。</p>
<p>oj_web_server需要设置环境变量<code>judger_token</code>,这样<code>judge_server</code>就可以在<code>OJ_WEB_SERVER_ENV_judger_token</code>环境变量中得到token<code>OJ_WEB_SERVER_PORT_8080_TCP_ADDR</code>得到ip<code>OJ_WEB_SERVER_PORT_8080_TCP_PORT</code>得到端口从而每5秒向该ip发送心跳包在HTTP头中携带了<code>X-JUDGE-SERVER-TOKEN</code>值为token的sha256。</p>
<h1 id="_1">跨主机场景</h1>
<p>如果不在同一台服务器上需要手动设置judge_server的下面四个环境变量</p>
<ul>
<li><code>service_discovery_url</code></li>
<li><code>judger_token</code></li>
</ul>
<p>通过以上两个环境变量这样就可以向该url发送心跳包了</p>
<ul>
<li><code>service_host</code></li>
<li><code>service_port</code></li>
</ul>
<p>因为跨主机的情况下oj_web_server是无法得知judge_server的ip和端口的需要主动的设置然后在心跳包中会带上这两个信息让oj_web_server能够主动访问。此时judge_server只能使用固定端口映射。</p></div>
</div>
<footer class="col-md-12">
<hr>
<center>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</center>
</footer>
<script src="../../../js/jquery-1.10.2.min.js"></script>
<script src="../../../js/bootstrap-3.0.3.min.js"></script>
<script src="../../../js/highlight.pack.js"></script>
<script>var base_url = '../../..';</script>
<script data-main="../../../mkdocs/js/search.js" src="../../../mkdocs/js/require.js"></script>
<script src="../../../js/base.js"></script>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Search</h4>
</div>
<div class="modal-body">
<p>
From here you can search these documents. Enter
your search terms below.
</p>
<form role="form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
</div>
</form>
<div id="mkdocs-search-results"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>

View File

@ -1,419 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="../../img/favicon.ico">
<title>API - Online Judge Docs</title>
<link href="../../css/bootstrap-custom.min.css" rel="stylesheet">
<link href="../../css/font-awesome-4.0.3.css" rel="stylesheet">
<link rel="stylesheet" href="../../css/highlight.css">
<link href="../../css/base.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Main title -->
<a class="navbar-brand" href="../..">Online Judge Docs</a>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav">
<li >
<a href="../..">Home</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Judger <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="../../Judger/">index</a>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">English</a>
<ul class="dropdown-menu">
<li >
<a href="../../Judger/English/">API</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="dropdown active">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">JudgeServer <b class="caret"></b></a>
<ul class="dropdown-menu">
<li >
<a href="../">index</a>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">English</a>
<ul class="dropdown-menu">
<li >
<a href="../English/">API</a>
</li>
<li >
<a href="../English/deploy/">Deploy</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a tabindex="-1" href="">中文</a>
<ul class="dropdown-menu">
<li class="active">
<a href="./">API</a>
</li>
<li >
<a href="deploy/">部署</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
<!-- Search, Navigation and Repo links -->
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#" data-toggle="modal" data-target="#mkdocs_search_modal">
<i class="fa fa-search"></i> Search
</a>
</li>
<li >
<a rel="next" href="../English/deploy/">
<i class="fa fa-arrow-left"></i> Previous
</a>
</li>
<li >
<a rel="prev" href="deploy/">
Next <i class="fa fa-arrow-right"></i>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container">
<div class="col-md-3"><div class="bs-sidebar hidden-print affix well" role="complementary">
<ul class="nav bs-sidenav">
<li class="main active"><a href="#judgeserver-api">JudgeServer API</a></li>
<li class="main "><a href="#_1">获取系统状态</a></li>
<li><a href="#_2">参数</a></li>
<li><a href="#_3">响应</a></li>
<li class="main "><a href="#special-judge">判题非Special Judge)</a></li>
<li><a href="#_4">参数</a></li>
<li><a href="#_5">响应</a></li>
<li class="main "><a href="#special-judge_1">编译Special Judge</a></li>
<li><a href="#_6">参数</a></li>
<li><a href="#_7">响应</a></li>
<li class="main "><a href="#special-judge_2">判题Special Judge)</a></li>
<li><a href="#_8">参数</a></li>
<li><a href="#_9">响应</a></li>
<li class="main "><a href="#result">result 字段含义</a></li>
</ul>
</div></div>
<div class="col-md-9" role="main">
<h1 id="judgeserver-api">JudgeServer API</h1>
<p>所有的请求请在HTTP头中放入<code>X-Judge-Server-Token</code>字段值为token的sha256结果。</p>
<p>所有的响应都是两个字段,<code>err</code><code>data</code>,正常情况下<code>err</code><code>null</code><code>data</code>为响应的数据。出现错误的情况下,<code>err</code>是错误代码,<code>data</code>为错误详情。下面所有的响应都是<code>data</code>的内容。</p>
<h1 id="_1">获取系统状态</h1>
<ul>
<li>URL <code>/ping</code></li>
<li>Method <code>POST</code></li>
</ul>
<h2 id="_2">参数</h2>
<ul>
<li>无参数</li>
</ul>
<h2 id="_3">响应</h2>
<pre><code class="js">{
&quot;judger_version&quot;: &quot;2.0.1&quot;,
&quot;hostname&quot;: &quot;d3765528134e&quot;,
// cpu核数这个数字也确定了可以并发运行的判题任务数量
&quot;cpu_core&quot;: 1,
// cpu和内存使用率百分比
&quot;cpu&quot;: 4.1,
&quot;memory&quot;: 24.5,
&quot;action&quot;: &quot;pong&quot;
}
</code></pre>
<h1 id="special-judge">判题非Special Judge)</h1>
<ul>
<li>URL <code>/judge</code></li>
<li>Method <code>POST</code></li>
</ul>
<h2 id="_4">参数</h2>
<ul>
<li>src源码</li>
<li>language_config参考<code>languages.py</code>中,一般不需要修改</li>
<li>max_cpu_time单位毫秒</li>
<li>max_memory最大内存单位字节</li>
<li>test_case_id用于找到存放有测试用例的文件夹</li>
</ul>
<h2 id="_5">响应</h2>
<pre><code class="js">[
// 每组都是一个测试用例通过test_case字段区分
{
// cpu时间毫秒
&quot;cpu_time&quot;: 1,
// 见本文档最后部分
&quot;result&quot;: 0,
// 内存,字节
&quot;memory&quot;: 12836864,
// 实际时间,毫秒
&quot;real_time&quot;: 2,
&quot;signal&quot;: 0,
&quot;error&quot;: 0,
&quot;exit_code&quot;: 0,
&quot;output_md5&quot;: &quot;eccbc87e4b5ce2fe28308fd9f2a7baf3&quot;,
// 测试用例id
&quot;test_case&quot;: 1
},
{
&quot;cpu_time&quot;: 1,
&quot;result&quot;: 0,
&quot;memory&quot;: 12849152,
&quot;real_time&quot;: 1,
&quot;signal&quot;: 0,
&quot;error&quot;: 0,
&quot;exit_code&quot;: 0,
&quot;output_md5&quot;: &quot;eccbc87e4b5ce2fe28308fd9f2a7baf3&quot;,
&quot;test_case&quot;: 2
}
]
</code></pre>
<p>在编译错误的时候,返回</p>
<pre><code class="js">{
&quot;err&quot;: &quot;CompileError&quot;,
&quot;data&quot;: &quot;编译器的错误输出&quot;
}
</code></pre>
<h1 id="special-judge_1">编译Special Judge</h1>
<ul>
<li>URL <code>/compile_spj</code></li>
<li>Method <code>POST</code></li>
</ul>
<h2 id="_6">参数</h2>
<ul>
<li>src源码</li>
<li>spj_versionSpecial Judge的版本用于决定是否要重新编译二进制</li>
<li>spj_compile_config参考<code>languages.py</code>,一般不需要修改</li>
<li>test_case_id</li>
</ul>
<h2 id="_7">响应</h2>
<pre><code class="js">&quot;success&quot;
</code></pre>
<p>在编译错误的时候,返回</p>
<pre><code class="js">{
&quot;err&quot;: &quot;SPJCompileError&quot;,
&quot;data&quot;: &quot;编译器的错误输出&quot;
}
</code></pre>
<h1 id="special-judge_2">判题Special Judge)</h1>
<p>注意必须提前编译Special Judge见上一个API</p>
<ul>
<li>URL <code>/judge</code></li>
<li>Method <code>POST</code></li>
</ul>
<h2 id="_8">参数</h2>
<ul>
<li>src</li>
<li>language_config</li>
<li>max_cpu_time</li>
<li>max_memory</li>
<li>test_case_id</li>
<li>spj_version</li>
<li>spj_config参考<code>languages.py</code>,一般不需要修改</li>
</ul>
<h2 id="_9">响应</h2>
<pre><code class="js">[
// 每组都是一个测试用例通过test_case字段区分
{
// cpu时间毫秒
&quot;cpu_time&quot;: 1,
// 见本文档最后部分
&quot;result&quot;: 0,
// 内存,字节
&quot;memory&quot;: 12836864,
// 实际时间,毫秒
&quot;real_time&quot;: 2,
&quot;signal&quot;: 0,
&quot;error&quot;: 0,
&quot;exit_code&quot;: 0,
&quot;output_md5&quot;: null,
// 测试用例id
&quot;test_case&quot;: 1
},
{
&quot;cpu_time&quot;: 1,
&quot;result&quot;: 0,
&quot;memory&quot;: 12849152,
&quot;real_time&quot;: 1,
&quot;signal&quot;: 0,
&quot;error&quot;: 0,
&quot;exit_code&quot;: 0,
&quot;output_md5&quot;: null,
&quot;test_case&quot;: 2
}
]
</code></pre>
<p>在编译错误的时候,返回</p>
<pre><code class="js">{
&quot;err&quot;: &quot;CompileError&quot;,
&quot;data&quot;: &quot;编译器的错误输出&quot;
}
</code></pre>
<h1 id="result">result 字段含义</h1>
<ul>
<li>WRONG_ANSWER = -1</li>
<li>AEECPTED = 0</li>
<li>CPU_TIME_LIMITED = 1</li>
<li>REAL_TIME_LIMIT_EXCEEDED = 2</li>
<li>MEMORY_LIMIT_EXCEEDED = 3</li>
<li>RUNTIME_ERROR = 4</li>
<li>SYSTEM_ERROR = 5</li>
</ul></div>
</div>
<footer class="col-md-12">
<hr>
<center>Documentation built with <a href="http://www.mkdocs.org/">MkDocs</a>.</center>
</footer>
<script src="../../js/jquery-1.10.2.min.js"></script>
<script src="../../js/bootstrap-3.0.3.min.js"></script>
<script src="../../js/highlight.pack.js"></script>
<script>var base_url = '../..';</script>
<script data-main="../../mkdocs/js/search.js" src="../../mkdocs/js/require.js"></script>
<script src="../../js/base.js"></script>
<div class="modal" id="mkdocs_search_modal" tabindex="-1" role="dialog" aria-labelledby="Search Modal" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="exampleModalLabel">Search</h4>
</div>
<div class="modal-body">
<p>
From here you can search these documents. Enter
your search terms below.
</p>
<form role="form">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search..." id="mkdocs-search-query">
</div>
</form>
<div id="mkdocs-search-results"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</body>
</html>