mirror of
https://github.com/Novartis/cellxgene-gateway.git
synced 2026-10-09 10:18:12 +08:00
#2 added link to relaunch server on process error page
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
|
||||||
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
# OR CONDITIONS OF ANY KIND, either express or implied. See the License for
|
||||||
# the specific language governing permissions and limitations under the License.
|
# the specific language governing permissions and limitations under the License.
|
||||||
|
import psutil
|
||||||
from flask import make_response, request
|
from flask import make_response, request
|
||||||
from requests import get, post, put
|
from requests import get, post, put
|
||||||
|
|
||||||
@@ -73,7 +74,8 @@ class CacheEntry:
|
|||||||
else:
|
else:
|
||||||
self.all_output += output
|
self.all_output += output
|
||||||
|
|
||||||
def terminate(self, process):
|
def terminate(self):
|
||||||
|
pid = self.pid
|
||||||
if pid != None and self.status != "terminated":
|
if pid != None and self.status != "terminated":
|
||||||
p = psutil.Process(pid)
|
p = psutil.Process(pid)
|
||||||
p.terminate()
|
p.terminate()
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ def handle_invalid_usage(error):
|
|||||||
"cellxgene_error.html",
|
"cellxgene_error.html",
|
||||||
extra_scripts=get_extra_scripts(),
|
extra_scripts=get_extra_scripts(),
|
||||||
message=message,
|
message=message,
|
||||||
|
path=error.path
|
||||||
),
|
),
|
||||||
error.http_status,
|
error.http_status,
|
||||||
)
|
)
|
||||||
@@ -67,7 +68,11 @@ def handle_invalid_process(error):
|
|||||||
render_template(
|
render_template(
|
||||||
"process_error.html",
|
"process_error.html",
|
||||||
extra_scripts=get_extra_scripts(),
|
extra_scripts=get_extra_scripts(),
|
||||||
message=message,
|
message=error.message,
|
||||||
|
http_status=error.http_status,
|
||||||
|
stdout=error.stdout,
|
||||||
|
stderr=error.stderr,
|
||||||
|
dataset=error.dataset,
|
||||||
),
|
),
|
||||||
error.http_status,
|
error.http_status,
|
||||||
)
|
)
|
||||||
@@ -180,7 +185,7 @@ def do_view(path):
|
|||||||
"loading.html", launchtime=launch_time, all_output=match.all_output
|
"loading.html", launchtime=launch_time, all_output=match.all_output
|
||||||
)
|
)
|
||||||
elif match.status == "error":
|
elif match.status == "error":
|
||||||
raise ProcessException.from_pid_object(match)
|
raise ProcessException.from_cache_entry(match)
|
||||||
|
|
||||||
@app.route("/cache_status", methods=["GET"])
|
@app.route("/cache_status", methods=["GET"])
|
||||||
def do_GET_status():
|
def do_GET_status():
|
||||||
@@ -195,7 +200,7 @@ def do_relaunch(path):
|
|||||||
match = cache.check_entry(dataset)
|
match = cache.check_entry(dataset)
|
||||||
if not match is None:
|
if not match is None:
|
||||||
match.terminate()
|
match.terminate()
|
||||||
return redirect(url_for('view', path=path), code=301)
|
return redirect(url_for('do_view', path=path), code=302)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
env.validate()
|
env.validate()
|
||||||
|
|||||||
@@ -9,18 +9,20 @@
|
|||||||
|
|
||||||
|
|
||||||
class ProcessException(Exception):
|
class ProcessException(Exception):
|
||||||
def __init__(self, message, stdout, stderr, http_status):
|
def __init__(self, message, stdout, stderr, http_status, dataset):
|
||||||
Exception.__init__(self)
|
Exception.__init__(self)
|
||||||
self.message = message
|
self.message = message
|
||||||
self.stdout = stdout
|
self.stdout = stdout
|
||||||
self.stderr = stderr
|
self.stderr = stderr
|
||||||
self.http_status = http_status
|
self.http_status = http_status
|
||||||
|
self.dataset = dataset
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_pid_object(cls, pid_object):
|
def from_cache_entry(cls, cache_entry):
|
||||||
return cls(
|
return cls(
|
||||||
pid_object.message,
|
cache_entry.message,
|
||||||
pid_object.all_output,
|
cache_entry.all_output,
|
||||||
pid_object.stderr,
|
cache_entry.stderr,
|
||||||
pid_object.http_status,
|
cache_entry.http_status,
|
||||||
|
cache_entry.dataset,
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import psutil
|
|
||||||
|
|
||||||
from cellxgene_gateway.util import current_time_stamp
|
from cellxgene_gateway.util import current_time_stamp
|
||||||
from cellxgene_gateway.env import ttl
|
from cellxgene_gateway.env import ttl
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class SubprocessBackend:
|
|||||||
cache_entry.status = "error"
|
cache_entry.status = "error"
|
||||||
cache_entry.set_error(message, stderr, http_status)
|
cache_entry.set_error(message, stderr, http_status)
|
||||||
|
|
||||||
raise ProcessException.from_pid_object(cache_entry)
|
raise ProcessException.from_cache_entry(cache_entry)
|
||||||
else:
|
else:
|
||||||
cache_entry.append_output(output)
|
cache_entry.append_output(output)
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
<th>dataset</th>
|
<th>dataset</th>
|
||||||
<th>port</th>
|
<th>port</th>
|
||||||
<th>launchtime</th>
|
<th>launchtime</th>
|
||||||
<th>timestamp</th>
|
<th>last access</th>
|
||||||
<th>status</th>
|
<th>status</th>
|
||||||
<th>message</th>
|
<th>message</th>
|
||||||
<th>http_status</th>
|
<th>http_status</th>
|
||||||
@@ -43,8 +43,8 @@
|
|||||||
<td>{{ entry.pid }}</td>
|
<td>{{ entry.pid }}</td>
|
||||||
<td>{{ entry.dataset }}</td>
|
<td>{{ entry.dataset }}</td>
|
||||||
<td>{{ entry.port }}</td>
|
<td>{{ entry.port }}</td>
|
||||||
<td>{{ entry.launchtime }}</td>
|
<td class="timestamp">{{ entry.launchtime }}</td>
|
||||||
<td>{{ entry.timestamp }}</td>
|
<td class="timestamp">{{ entry.timestamp }}</td>
|
||||||
<td>{{ entry.status }}</td>
|
<td>{{ entry.status }}</td>
|
||||||
<td>{{ entry.message }}</td>
|
<td>{{ entry.message }}</td>
|
||||||
<td>{{ entry.http_status }}</td>
|
<td>{{ entry.http_status }}</td>
|
||||||
@@ -52,5 +52,15 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
<script>
|
||||||
|
$(() => {
|
||||||
|
$(".timestamp").each(function(){
|
||||||
|
const el = $(this);
|
||||||
|
const ts = el.text();
|
||||||
|
const dt = new Date(parseInt(ts * 1000));
|
||||||
|
el.html(`${dt.toISOString()}<br>(${ts})`);
|
||||||
|
});
|
||||||
|
})
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -39,6 +39,11 @@
|
|||||||
<u>File Crawler: Allows you to view all uploaded data.</u></a>
|
<u>File Crawler: Allows you to view all uploaded data.</u></a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="list-group" style="width:50%;padding-left:65px">
|
||||||
|
<a href="/cache_status" class="list-group-item list-group-item-action">
|
||||||
|
<u>Cache Status: view status of launched cellxgene servers.</u></a>
|
||||||
|
</div>
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
<h1 style="padding-left:35px">
|
<h1 style="padding-left:35px">
|
||||||
@@ -103,9 +108,5 @@ scp -r pbmc3k.h5ad ec2-user@{{ ip }}:{{ cellxgene_data }}/USER/DATA/</pre>
|
|||||||
<li>Take a look at your data using the file crawler link above</li>
|
<li>Take a look at your data using the file crawler link above</li>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li><a href="/cache_status.html">Cache Status<</a> - view status of currently loaded datasets</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -25,19 +25,27 @@
|
|||||||
</header>
|
</header>
|
||||||
<br>
|
<br>
|
||||||
<div style="margin-left:20px">
|
<div style="margin-left:20px">
|
||||||
|
<h4>Error Details</h4>
|
||||||
<h4>{{ message[0] }}</h4>
|
<table>
|
||||||
<h4>{{ message[1] }}</h4>
|
<tr><th>Message</th><td>{{ message }}</td></tr>
|
||||||
<h4>{{ message[2] }}</h4>
|
<tr><th>Status</th><td>{{ http_status }}</td></tr>
|
||||||
<h4>{{ message[3] }}</h4>
|
<tr><th>Stdout</th><td>{{ stdout }}</td></tr>
|
||||||
|
<tr><th>Stderr</th><td>{{ stderr }}</td></tr>
|
||||||
<a href="/filecrawl.html">
|
</table>
|
||||||
Please click here to be redirected to the file directory.
|
<br>
|
||||||
</a>
|
<h4>Options</h4>
|
||||||
<br>
|
Please choose one of the following, or use the back button:
|
||||||
<a href="/">
|
<ul>
|
||||||
Please click here to return to the homepage.
|
<li><a href="{{url_for('do_relaunch', path=dataset)}}">
|
||||||
</a>
|
Attempt to relaunch the cellxgene server.
|
||||||
</div>
|
</a></li>
|
||||||
|
<li><a href="/filecrawl.html">
|
||||||
|
Return to the file directory.
|
||||||
|
</a></li>
|
||||||
|
<li><a href="/">
|
||||||
|
Return to the homepage.
|
||||||
|
</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user