Spaces:
Running
Running
Commit
·
a876792
1
Parent(s):
5b7a2c5
now excluding -journal files from the mirroring
Browse files- hf_server.js +49 -17
- omnitool_init.sh +1 -1
hf_server.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* All rights reserved.
|
4 |
*/
|
5 |
//@ts-check
|
6 |
-
const VERSION = '0.6.0.hf.014.
|
7 |
|
8 |
const express = require('express');
|
9 |
const http = require('http');
|
@@ -29,7 +29,7 @@ const HF_SPACE_URL = "https://huggingface.co/spaces/omnitool-ai/omnitool_on_hf";
|
|
29 |
const HF_SPACE_DUPLICATE_URL = "https://huggingface.co/spaces/omnitool-ai/omnitool_on_hf?duplicate=true";
|
30 |
|
31 |
const sourceDir = './omnitool/packages/omni-server/data.local';
|
32 |
-
const targetDir = '/data
|
33 |
|
34 |
const DELAY_OMNITOOL_SET_TO_RUNNING = 2000; // 2 seconds
|
35 |
const CHECK_OMNI_INTERVAL = 60000; // 1 minute
|
@@ -517,7 +517,16 @@ main(app);
|
|
517 |
|
518 |
function startMirrorToDataDir()
|
519 |
{
|
520 |
-
if (!fs.existsSync(targetDir))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
521 |
|
522 |
const watcher = chokidar.watch(sourceDir, {
|
523 |
ignored: /[\/\\]\./,
|
@@ -526,8 +535,10 @@ function startMirrorToDataDir()
|
|
526 |
|
527 |
watcher
|
528 |
.on('add', function(path) {
|
|
|
|
|
529 |
const targetFile = path.replace(sourceDir, targetDir);
|
530 |
-
console.warn(`TargetFile = ${targetFile}. File ${path} would have been added and copied from ${sourceDir} to ${targetDir}`);
|
531 |
try {
|
532 |
fs.copyFile(path, targetFile, (err) => {
|
533 |
if (err)
|
@@ -542,23 +553,44 @@ function startMirrorToDataDir()
|
|
542 |
}
|
543 |
})
|
544 |
.on('change', function(path) {
|
|
|
|
|
545 |
const targetFile = path.replace(sourceDir, targetDir);
|
546 |
-
console.warn(`TargetFile = ${targetFile}. File ${path} would have been changed and copied from ${sourceDir} to ${targetDir}`);
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
553 |
})
|
554 |
.on('unlink', function(path) {
|
|
|
|
|
555 |
const targetFile = path.replace(sourceDir, targetDir);
|
556 |
-
console.warn(`TargetFile = ${targetFile}. File ${path} would have been removed from ${targetDir}`);
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
562 |
});
|
563 |
|
564 |
return watcher;
|
|
|
3 |
* All rights reserved.
|
4 |
*/
|
5 |
//@ts-check
|
6 |
+
const VERSION = '0.6.0.hf.014.k';
|
7 |
|
8 |
const express = require('express');
|
9 |
const http = require('http');
|
|
|
29 |
const HF_SPACE_DUPLICATE_URL = "https://huggingface.co/spaces/omnitool-ai/omnitool_on_hf?duplicate=true";
|
30 |
|
31 |
const sourceDir = './omnitool/packages/omni-server/data.local';
|
32 |
+
const targetDir = '/data';
|
33 |
|
34 |
const DELAY_OMNITOOL_SET_TO_RUNNING = 2000; // 2 seconds
|
35 |
const CHECK_OMNI_INTERVAL = 60000; // 1 minute
|
|
|
517 |
|
518 |
function startMirrorToDataDir()
|
519 |
{
|
520 |
+
if (!fs.existsSync(targetDir))
|
521 |
+
{
|
522 |
+
console.warn(`---------> Target directory ${targetDir} does not exist. Not starting mirroring.`);
|
523 |
+
return;
|
524 |
+
}
|
525 |
+
else
|
526 |
+
{
|
527 |
+
console.warn(`---------> Target directory ${targetDir} exists. Starting mirroring.`);
|
528 |
+
|
529 |
+
}
|
530 |
|
531 |
const watcher = chokidar.watch(sourceDir, {
|
532 |
ignored: /[\/\\]\./,
|
|
|
535 |
|
536 |
watcher
|
537 |
.on('add', function(path) {
|
538 |
+
if (path.includes('-journal')) return;
|
539 |
+
|
540 |
const targetFile = path.replace(sourceDir, targetDir);
|
541 |
+
//console.warn(`TargetFile = ${targetFile}. File ${path} would have been added and copied from ${sourceDir} to ${targetDir}`);
|
542 |
try {
|
543 |
fs.copyFile(path, targetFile, (err) => {
|
544 |
if (err)
|
|
|
553 |
}
|
554 |
})
|
555 |
.on('change', function(path) {
|
556 |
+
if (path.includes('-journal')) return;
|
557 |
+
|
558 |
const targetFile = path.replace(sourceDir, targetDir);
|
559 |
+
//console.warn(`TargetFile = ${targetFile}. File ${path} would have been changed and copied from ${sourceDir} to ${targetDir}`);
|
560 |
+
try{
|
561 |
+
fs.copyFile(path, targetFile, (err) => {
|
562 |
+
if (err)
|
563 |
+
{
|
564 |
+
//throw err;
|
565 |
+
console.error('ERROR when doing: File', path, 'has been changed and copied to', targetFile);
|
566 |
+
}
|
567 |
+
});
|
568 |
+
}
|
569 |
+
catch(error)
|
570 |
+
{
|
571 |
+
console.error(`WATCHER: error: ${error}`);
|
572 |
+
}
|
573 |
+
|
574 |
})
|
575 |
.on('unlink', function(path) {
|
576 |
+
if (path.includes('-journal')) return;
|
577 |
+
|
578 |
const targetFile = path.replace(sourceDir, targetDir);
|
579 |
+
//console.warn(`TargetFile = ${targetFile}. File ${path} would have been removed from ${targetDir}`);
|
580 |
+
try
|
581 |
+
{
|
582 |
+
fs.unlink(targetFile, (err) => {
|
583 |
+
if (err)
|
584 |
+
{
|
585 |
+
// throw err;
|
586 |
+
console.log('ERROR when doing: File', path, 'has been removed');
|
587 |
+
}
|
588 |
+
});
|
589 |
+
}
|
590 |
+
catch(error)
|
591 |
+
{
|
592 |
+
console.error(`WATCHER: error: ${error}`);
|
593 |
+
}
|
594 |
});
|
595 |
|
596 |
return watcher;
|
omnitool_init.sh
CHANGED
@@ -41,4 +41,4 @@ else
|
|
41 |
fi
|
42 |
|
43 |
echo "[->] YARN START "
|
44 |
-
yarn start -u -rb -R blocks
|
|
|
41 |
fi
|
42 |
|
43 |
echo "[->] YARN START "
|
44 |
+
yarn start -u -rb -ll 2 -R blocks
|