c'est une bien meilleure manière de faire.
This commit is contained in:
parent
e2ab390b01
commit
1e7f283e80
|
@ -7,8 +7,9 @@ RUN curl -sSLO https://piair.xyz/download/chrome.deb \
|
||||||
&& python3 -m pip install -r MsRewards-Reborn/requirements.txt \
|
&& python3 -m pip install -r MsRewards-Reborn/requirements.txt \
|
||||||
&& wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key \
|
&& wget -q -O /usr/share/keyrings/grafana.key https://apt.grafana.com/gpg.key \
|
||||||
&& echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list \
|
&& echo "deb [signed-by=/usr/share/keyrings/grafana.key] https://apt.grafana.com stable main" | tee -a /etc/apt/sources.list.d/grafana.list \
|
||||||
|
&& echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | tee /etc/apt/sources.list.d/redis.list \
|
||||||
&& apt update \
|
&& apt update \
|
||||||
&& apt install novnc websockify grafana xvfb nginx nano tzdata sqlite3 apt-transport-https software-properties-common wget wfrench tigervnc-standalone-server libasound2 libatk-bridge2.0-0 libnss3 libnspr4 xvfb libgbm1 libatk1.0-0 libu2f-udev libatspi2.0-0 libcups2 libxkbcommon0 libxrandr2 libdbus-1-3 xdg-utils fonts-liberation libdrm2 -y \
|
&& apt install redis novnc websockify grafana xvfb nginx nano tzdata sqlite3 apt-transport-https software-properties-common wget wfrench tigervnc-standalone-server libasound2 libatk-bridge2.0-0 libnss3 libnspr4 xvfb libgbm1 libatk1.0-0 libu2f-udev libatspi2.0-0 libcups2 libxkbcommon0 libxrandr2 libdbus-1-3 xdg-utils fonts-liberation libdrm2 -y \
|
||||||
&& bash MsRewards-Reborn/config/config.sh \
|
&& bash MsRewards-Reborn/config/config.sh \
|
||||||
&& dpkg -i chrome.deb
|
&& dpkg -i chrome.deb
|
||||||
|
|
||||||
|
|
15
Flask/app.py
15
Flask/app.py
|
@ -10,6 +10,21 @@ import json
|
||||||
import re
|
import re
|
||||||
from requests import get
|
from requests import get
|
||||||
|
|
||||||
|
# redis part for live update
|
||||||
|
redis_client = redis.StrictRedis(host='localhost', port=6379, db=0)
|
||||||
|
pubsub = redis_client.pubsub()
|
||||||
|
pubsub.subscribe('console')
|
||||||
|
|
||||||
|
def generate_output():
|
||||||
|
for message in pubsub.listen():
|
||||||
|
if message['type'] == 'message':
|
||||||
|
yield f"data: {message['data'].decode()}\n\n"
|
||||||
|
|
||||||
|
@app.route('/stream')
|
||||||
|
def stream():
|
||||||
|
return Response(generate_output(), content_type='text/event-stream')
|
||||||
|
# end
|
||||||
|
|
||||||
global password
|
global password
|
||||||
with open("/app/MsRewards-Reborn/user_data/flask.json", "r") as inFile:
|
with open("/app/MsRewards-Reborn/user_data/flask.json", "r") as inFile:
|
||||||
data = json.load(inFile)
|
data = json.load(inFile)
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
service grafana-server start
|
service grafana-server start
|
||||||
service nginx start
|
service nginx start
|
||||||
gunicorn --reload -w 1 -b 0.0.0.0:6666 'app:app'
|
nohup redis-server &
|
||||||
|
gunicorn --reload -w 1 --worker-class gevent -b 0.0.0.0:6666 'app:app'
|
||||||
|
|
|
@ -7,20 +7,23 @@
|
||||||
{%if not current_user.is_authenticated %}
|
{%if not current_user.is_authenticated %}
|
||||||
<button class="unselected" onclick="location.href = '/login';">login</button>
|
<button class="unselected" onclick="location.href = '/login';">login</button>
|
||||||
{% else %}
|
{% else %}
|
||||||
<iframe id="iframe" src="{{url_for('static', filename='logs/dev.txt')}}" width="100%" height="80%"></iframe>
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td width="20%" height="90%">
|
||||||
|
<div id="console"></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var myIframe = document.getElementById('iframe');
|
const consoleElement = document.getElementById('console');
|
||||||
|
const eventSource = new EventSource('/stream');
|
||||||
|
|
||||||
myIframe.addEventListener("load", async () => {
|
eventSource.onmessage = (event) => {
|
||||||
myIframe.contentDocument.body.innerHTML = myIframe.contentDocument.body.innerHTML + '<style>html{color:white;}</style>';
|
const newOutput = document.createElement('div');
|
||||||
await delay(2000);
|
newOutput.textContent = event.data;
|
||||||
document.getElementById('iframe').contentWindow.location.reload();
|
consoleElement.appendChild(newOutput);
|
||||||
});
|
};
|
||||||
|
|
||||||
window.setInterval(function() {
|
|
||||||
document.getElementById('iframe').contentWindow.scrollTo(0, myIframe.contentDocument.body.scrollHeight);
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -9,23 +9,26 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td width="20%" height="90%"><iframe id="iframe" src="{{url_for('static', filename='logs/custom.txt')}}" width="100%" height="100%"></iframe></td>
|
<td width="20%" height="90%">
|
||||||
<td width="80%"><iframe src="/novnc/vnc.html?resize=scale&path=novnc/websockify&autoconnect=true&view_only" width="100%" height="100%" frameborder="0"></iframe></td>
|
<div id="console"></div>
|
||||||
|
</td>
|
||||||
|
<td width="80%">
|
||||||
|
<iframe src="/novnc/vnc.html?resize=scale&path=novnc/websockify&autoconnect=true&view_only" width="100%" height="100%" frameborder="0"></iframe>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
var myIframe = document.getElementById('iframe');
|
const consoleElement = document.getElementById('console');
|
||||||
|
const eventSource = new EventSource('/stream');
|
||||||
|
|
||||||
myIframe.addEventListener("load", async () => {
|
eventSource.onmessage = (event) => {
|
||||||
myIframe.contentDocument.body.innerHTML = myIframe.contentDocument.body.innerHTML + '<style>html{color:white;}</style>';
|
const newOutput = document.createElement('div');
|
||||||
await delay(2000);
|
newOutput.textContent = event.data;
|
||||||
document.getElementById('iframe').contentWindow.location.reload();
|
consoleElement.appendChild(newOutput);
|
||||||
});
|
};
|
||||||
|
|
||||||
window.setInterval(function() {
|
|
||||||
document.getElementById('iframe').contentWindow.scrollTo(0, myIframe.contentDocument.body.scrollHeight);
|
|
||||||
}, 500);
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -13,3 +13,5 @@ packaging
|
||||||
apscheduler
|
apscheduler
|
||||||
flask_login
|
flask_login
|
||||||
gunicorn
|
gunicorn
|
||||||
|
gevent
|
||||||
|
redis
|
Loading…
Reference in New Issue