Spaces:
Running
Running
Commit
·
fadd78e
1
Parent(s):
1e8d830
added info about fixing the 404 issue. Added log error window
Browse files- Dockerfile +6 -3
- hf_server.js +41 -19
- omnitool_init.sh +14 -22
Dockerfile
CHANGED
@@ -1,13 +1,16 @@
|
|
1 |
FROM node:20.6.1
|
2 |
|
|
|
|
|
|
|
|
|
3 |
USER node
|
4 |
WORKDIR /app
|
5 |
|
6 |
-
|
7 |
-
#RUN cd /app
|
8 |
RUN git clone https://github.com/omnitool-ai/omnitool.git
|
9 |
RUN cd omnitool && yarn install
|
10 |
-
|
11 |
RUN mkdir -p /app/omnitool/node_modules
|
12 |
RUN chmod 0777 /app
|
13 |
RUN chown -Rh $user:$user /app
|
|
|
1 |
FROM node:20.6.1
|
2 |
|
3 |
+
USER root
|
4 |
+
RUN mkdir -p /data
|
5 |
+
RUN chmod 0777 /data
|
6 |
+
|
7 |
USER node
|
8 |
WORKDIR /app
|
9 |
|
10 |
+
RUN chown -Rh $user:$user /data
|
|
|
11 |
RUN git clone https://github.com/omnitool-ai/omnitool.git
|
12 |
RUN cd omnitool && yarn install
|
13 |
+
|
14 |
RUN mkdir -p /app/omnitool/node_modules
|
15 |
RUN chmod 0777 /app
|
16 |
RUN chown -Rh $user:$user /app
|
hf_server.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* All rights reserved.
|
4 |
*/
|
5 |
//@ts-check
|
6 |
-
const VERSION = '0.6.0.hf.
|
7 |
|
8 |
const express = require('express');
|
9 |
const http = require('http');
|
@@ -44,6 +44,7 @@ global.PING_URL = "";
|
|
44 |
global.PROTOCOL = "";
|
45 |
global.PROXY_STARTED = false;
|
46 |
global.logs = [];
|
|
|
47 |
global.OMNITOOL_PROXY = null;
|
48 |
global.CONNECTED_TO_MASTER = false;
|
49 |
|
@@ -52,7 +53,7 @@ global.CONNECTED_TO_MASTER = false;
|
|
52 |
console.log(`************ Omnitool Proxy Server v${VERSION} ************`);
|
53 |
|
54 |
// HTML templates and constants
|
55 |
-
const LOG_CONTAINER_HTML = `<div id="logContainer"></div>`;
|
56 |
const COMMON_STYLES =
|
57 |
`<style>
|
58 |
#logContainer {
|
@@ -65,6 +66,16 @@ const COMMON_STYLES =
|
|
65 |
white-space: pre-wrap;
|
66 |
border: 1px solid #ddd;
|
67 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
.highlight-button {
|
69 |
animation: pulseAnimation 1s infinite;
|
70 |
background-color: yellow;
|
@@ -150,7 +161,9 @@ const COMMON_STYLES =
|
|
150 |
{
|
151 |
const logContainer = document.getElementById('logContainer');
|
152 |
logContainer.innerText = data.logs.join("");
|
153 |
-
|
|
|
|
|
154 |
if (data.ready)
|
155 |
{
|
156 |
if (document.getElementById('refreshButton').disabled == true)
|
@@ -223,7 +236,7 @@ async function startOmnitoolServer()
|
|
223 |
global.logs.shift(); // Remove the oldest log entry
|
224 |
}
|
225 |
global.logs.push(data.toString());
|
226 |
-
console.log(`[
|
227 |
|
228 |
if (!global.OMNITOOL_RUNNING)
|
229 |
{
|
@@ -237,8 +250,12 @@ async function startOmnitoolServer()
|
|
237 |
|
238 |
omnitoolStartProcess.stderr.on('data', (data) =>
|
239 |
{
|
240 |
-
|
241 |
-
|
|
|
|
|
|
|
|
|
242 |
});
|
243 |
|
244 |
omnitoolStartProcess.on('close', (code) =>
|
@@ -275,7 +292,7 @@ function setOmnitoolRunning(set_running)
|
|
275 |
}, DELAY_OMNITOOL_SET_TO_RUNNING); // Delay by 2 second
|
276 |
|
277 |
// start mirroring to /data when the server is running
|
278 |
-
startMirrorToDataDir();
|
279 |
|
280 |
}
|
281 |
|
@@ -335,7 +352,7 @@ async function handleGetStartOmnitoolServer(req, res)
|
|
335 |
async function handleGetOmnitoolLogs(req, res)
|
336 |
{
|
337 |
res.writeHead(200, { 'Content-Type': 'application/json' });
|
338 |
-
const reply = { logs: global.logs, ready: global.OMNITOOL_READY };
|
339 |
res.end(JSON.stringify(reply));
|
340 |
return;
|
341 |
}
|
@@ -386,19 +403,24 @@ async function handleGetRoot(req, res)
|
|
386 |
{
|
387 |
let page_message ="";
|
388 |
|
389 |
-
page_message += '<div style="color: red;">
|
390 |
page_message += '<p></p>';
|
391 |
-
page_message += '<div>
|
392 |
-
page_message += '<div>
|
393 |
-
page_message += '<div>
|
394 |
-
page_message +=
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
395 |
page_message += '<p></p>';
|
396 |
|
397 |
const SCRIPTS = getScriptsHtml();
|
398 |
|
399 |
-
let buttonsHTML = `
|
400 |
-
<a href="${HF_SPACE_DUPLICATE_URL}" target="_blank" class="button-like-link" id="duplicateRepoButton">DUPLICATE SPACE</a>`;
|
401 |
-
|
402 |
const page_html = `
|
403 |
<html>
|
404 |
<head>
|
@@ -648,7 +670,7 @@ function startMirrorToDataDir()
|
|
648 |
//throw err;
|
649 |
const error_message = `ERROR when doing: File ${file_path} added -> copied to ${targetFile}\n`;
|
650 |
console.log(error_message);
|
651 |
-
global.
|
652 |
}});
|
653 |
}
|
654 |
catch(error)
|
@@ -670,7 +692,7 @@ function startMirrorToDataDir()
|
|
670 |
//throw err;
|
671 |
const error_message = `ERROR when doing: File ${file_path} changed -> copied to ${targetFile}\n`;
|
672 |
console.log(error_message);
|
673 |
-
global.
|
674 |
}
|
675 |
});
|
676 |
}
|
@@ -695,7 +717,7 @@ function startMirrorToDataDir()
|
|
695 |
// throw err;
|
696 |
const error_message = `ERROR when doing: File ${file_path} has been removed from ${targetDir}\n`;
|
697 |
console.log(error_message);
|
698 |
-
global.
|
699 |
}
|
700 |
});
|
701 |
}
|
|
|
3 |
* All rights reserved.
|
4 |
*/
|
5 |
//@ts-check
|
6 |
+
const VERSION = '0.6.0.hf.016.e';
|
7 |
|
8 |
const express = require('express');
|
9 |
const http = require('http');
|
|
|
44 |
global.PROTOCOL = "";
|
45 |
global.PROXY_STARTED = false;
|
46 |
global.logs = [];
|
47 |
+
global.error_logs = [];
|
48 |
global.OMNITOOL_PROXY = null;
|
49 |
global.CONNECTED_TO_MASTER = false;
|
50 |
|
|
|
53 |
console.log(`************ Omnitool Proxy Server v${VERSION} ************`);
|
54 |
|
55 |
// HTML templates and constants
|
56 |
+
const LOG_CONTAINER_HTML = `<div id="logContainer"></div><div id="errorContainer"></div>`;
|
57 |
const COMMON_STYLES =
|
58 |
`<style>
|
59 |
#logContainer {
|
|
|
66 |
white-space: pre-wrap;
|
67 |
border: 1px solid #ddd;
|
68 |
}
|
69 |
+
#errorContainer {
|
70 |
+
height: 400px;
|
71 |
+
overflow-y: scroll;
|
72 |
+
background-color: red;
|
73 |
+
color: white;
|
74 |
+
font-family: 'Courier New', Courier, monospace;
|
75 |
+
padding: 10px;
|
76 |
+
white-space: pre-wrap;
|
77 |
+
border: 1px solid #ddd;
|
78 |
+
}
|
79 |
.highlight-button {
|
80 |
animation: pulseAnimation 1s infinite;
|
81 |
background-color: yellow;
|
|
|
161 |
{
|
162 |
const logContainer = document.getElementById('logContainer');
|
163 |
logContainer.innerText = data.logs.join("");
|
164 |
+
const errorContainer = document.getElementById('errorContainer');
|
165 |
+
errorContainer.innerText = data.error_logs.join("");
|
166 |
+
|
167 |
if (data.ready)
|
168 |
{
|
169 |
if (document.getElementById('refreshButton').disabled == true)
|
|
|
236 |
global.logs.shift(); // Remove the oldest log entry
|
237 |
}
|
238 |
global.logs.push(data.toString());
|
239 |
+
console.log(`[log] ${data}`);
|
240 |
|
241 |
if (!global.OMNITOOL_RUNNING)
|
242 |
{
|
|
|
250 |
|
251 |
omnitoolStartProcess.stderr.on('data', (data) =>
|
252 |
{
|
253 |
+
if (global.error_logs.length >= MAX_LOG_SIZE) {
|
254 |
+
global.error_logs.shift(); // Remove the oldest log entry
|
255 |
+
}
|
256 |
+
|
257 |
+
console.error(`[stderr] ${data}`);
|
258 |
+
global.error_logs.push(data.toString());
|
259 |
});
|
260 |
|
261 |
omnitoolStartProcess.on('close', (code) =>
|
|
|
292 |
}, DELAY_OMNITOOL_SET_TO_RUNNING); // Delay by 2 second
|
293 |
|
294 |
// start mirroring to /data when the server is running
|
295 |
+
// startMirrorToDataDir(); #DISABLED!
|
296 |
|
297 |
}
|
298 |
|
|
|
352 |
async function handleGetOmnitoolLogs(req, res)
|
353 |
{
|
354 |
res.writeHead(200, { 'Content-Type': 'application/json' });
|
355 |
+
const reply = { logs: global.logs, error_logs: global.error_logs, ready: global.OMNITOOL_READY };
|
356 |
res.end(JSON.stringify(reply));
|
357 |
return;
|
358 |
}
|
|
|
403 |
{
|
404 |
let page_message ="";
|
405 |
|
406 |
+
page_message += '<div style="color: red;">This is the REFERENCE Omnitool Space on Huggingface.</div>';
|
407 |
page_message += '<p></p>';
|
408 |
+
page_message += '<div>To access Omnitool, you must first DUPLICATE this SPACE to make it your own.</div>';
|
409 |
+
page_message += '<div>Duplicating the Space will help secure your keys, recipes and outputs.</div>';
|
410 |
+
page_message += '<div>Please set your Space as PRIVATE!</div>';
|
411 |
+
page_message += '<div>DUPLICATING and using your own SPACE is FREE if you use the lowest tier of CPU. No GPU is required.</div>';
|
412 |
+
page_message += `<div>DUPLICATING this space is done by pressing this button: <a href="${HF_SPACE_DUPLICATE_URL}" target="_blank" class="button-like-link" id="duplicateRepoButton">DUPLICATE SPACE</a></div>`;
|
413 |
+
page_message += "<div>However, you can try using the 20 Gig Storage option (~ 5 USD/month) to persist keys, recipes and outputs between server restarts. This is still a BETA feature!</div>";
|
414 |
+
page_message += '<p></p>';
|
415 |
+
page_message += '<div style="color: red;">Some users have reported getting a 404 error when pressing the yellow START button after duplicating the space. If that happens to you follow the following instructions</div>';
|
416 |
+
page_message += '<div> - go to settings and set the space to PUBLIC</div>';
|
417 |
+
page_message += '<div> - confirm that the START button now works</div>';
|
418 |
+
page_message += '<div> - go to settings and set the Space back to PRIVATE</div>';
|
419 |
+
page_message += '<div> - in settings, FACTORY REBUILD your Space</div>';
|
420 |
page_message += '<p></p>';
|
421 |
|
422 |
const SCRIPTS = getScriptsHtml();
|
423 |
|
|
|
|
|
|
|
424 |
const page_html = `
|
425 |
<html>
|
426 |
<head>
|
|
|
670 |
//throw err;
|
671 |
const error_message = `ERROR when doing: File ${file_path} added -> copied to ${targetFile}\n`;
|
672 |
console.log(error_message);
|
673 |
+
global.error_logs.push(error_message);
|
674 |
}});
|
675 |
}
|
676 |
catch(error)
|
|
|
692 |
//throw err;
|
693 |
const error_message = `ERROR when doing: File ${file_path} changed -> copied to ${targetFile}\n`;
|
694 |
console.log(error_message);
|
695 |
+
global.error_logs.push(error_message);
|
696 |
}
|
697 |
});
|
698 |
}
|
|
|
717 |
// throw err;
|
718 |
const error_message = `ERROR when doing: File ${file_path} has been removed from ${targetDir}\n`;
|
719 |
console.log(error_message);
|
720 |
+
global.error_logs.push(error_message);
|
721 |
}
|
722 |
});
|
723 |
}
|
omnitool_init.sh
CHANGED
@@ -2,35 +2,22 @@
|
|
2 |
echo "[->] START "
|
3 |
|
4 |
echo "[->] CHECKING EXISTING /DATA "
|
5 |
-
|
6 |
-
|
|
|
7 |
else
|
8 |
echo "[<] NO persistent /DATA DETECTED. You can add 20Gig of persistent storage as a paid option to Hugging Face"
|
|
|
|
|
9 |
fi
|
10 |
|
11 |
-
|
12 |
-
# rm -rf ./omnitool/packages/omni-server/data.local
|
13 |
-
# fi
|
14 |
-
|
15 |
-
# if [ -d "./omnitool/packages/omni-server/data.local" ]; then
|
16 |
-
# echo "[v] DATA.LOCAL already present "
|
17 |
-
# rm -rf ./omnitool/packages/omni-server/data.local # hopefully it got copied over through the symlink in the previous run
|
18 |
-
# fi
|
19 |
-
|
20 |
-
# echo "[v] Creating the symlink "
|
21 |
-
# ln -s /data ./omnitool/packages/omni-server/data.local
|
22 |
-
# chmod 0777 ./omnitool/packages/omni-server/data.local
|
23 |
-
# chown node ./omnitool/packages/omni-server/data.local
|
24 |
-
# else
|
25 |
-
# echo "[v] NO persistent /DATA DETECTED. You can add 20Gig of persistent storage as a paid option to Hugging Face"
|
26 |
-
# fi
|
27 |
-
|
28 |
echo "[->] UPDATE OMNITOOL if needed"
|
29 |
cd ./omnitool
|
30 |
-
output=$(git pull)
|
31 |
|
32 |
-
|
|
|
33 |
|
|
|
34 |
if echo "$output" | grep -q "Already up to date."; then
|
35 |
echo "The repository is already up to date."
|
36 |
else
|
@@ -43,5 +30,10 @@ else
|
|
43 |
chown -Rh node:node .
|
44 |
fi
|
45 |
|
|
|
|
|
|
|
|
|
|
|
46 |
echo "[->] YARN START "
|
47 |
-
yarn start -u -rb -ll
|
|
|
2 |
echo "[->] START "
|
3 |
|
4 |
echo "[->] CHECKING EXISTING /DATA "
|
5 |
+
# was: /data
|
6 |
+
if [ -d "../data" ]; then
|
7 |
+
echo "$(ls -l ../data)"
|
8 |
else
|
9 |
echo "[<] NO persistent /DATA DETECTED. You can add 20Gig of persistent storage as a paid option to Hugging Face"
|
10 |
+
echo "$(mkdir -p ../data)"
|
11 |
+
echo "$(ls -l ../data)"
|
12 |
fi
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
echo "[->] UPDATE OMNITOOL if needed"
|
15 |
cd ./omnitool
|
|
|
16 |
|
17 |
+
#echo "[->] Restoring .mercs.yaml first"
|
18 |
+
#git restore .mercs.yaml
|
19 |
|
20 |
+
output=$(git pull)
|
21 |
if echo "$output" | grep -q "Already up to date."; then
|
22 |
echo "The repository is already up to date."
|
23 |
else
|
|
|
30 |
chown -Rh node:node .
|
31 |
fi
|
32 |
|
33 |
+
#echo "[->] UPDATE OMNITOOL data storage location"
|
34 |
+
#mv ./.mercs.yaml ./.mercs.yaml.original
|
35 |
+
#sed 's|./data.local|../../../../data/data.local|g' ./.mercs.yaml.original > ./.mercs.yaml
|
36 |
+
#rm ./.mercs.yaml.original
|
37 |
+
|
38 |
echo "[->] YARN START "
|
39 |
+
yarn start -u -rb -ll 3 -R blocks
|