Updates
This commit is contained in:
parent
68c1074de1
commit
37a314273a
33
README.md
33
README.md
@ -84,3 +84,36 @@ You can also use environment variables in the config file. Example:
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
## System Processes
|
||||
|
||||
Run Turbosync as a system process to keep it running in the background.
|
||||
|
||||
### Systemd Config
|
||||
|
||||
Use this template to create a systemd service for turbosync.
|
||||
|
||||
```ini
|
||||
[Unit]
|
||||
Description=Service Name
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/home/user/.bun/bin/turbosync
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
Environment="PATH=/usr/bin:/home/user/.bun/bin:/home/user/.nvm/versions/node/v20.18.1/bin:${PATH}"
|
||||
User=user
|
||||
WorkingDirectory=/home/user/services/turbosync/service-name
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
```
|
||||
|
||||
After this you can run:
|
||||
|
||||
```bash
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable turbosync-service-name
|
||||
sudo systemctl start turbosync-service-name
|
||||
```
|
||||
|
4
dist/lib/watch/files.js
vendored
4
dist/lib/watch/files.js
vendored
@ -16,10 +16,10 @@ exports.default = watchFiles;
|
||||
const child_process_1 = require("child_process");
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const delay_1 = __importDefault(require("../../utils/delay"));
|
||||
let timeout;
|
||||
const UPDATE_TIMEOUT = 2000;
|
||||
function watchFiles(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ files, options, }) {
|
||||
let timeout;
|
||||
const UPDATE_TIMEOUT = 2000;
|
||||
try {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
|
8
dist/lib/watch/folders.js
vendored
8
dist/lib/watch/folders.js
vendored
@ -17,10 +17,10 @@ const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const child_process_1 = require("child_process");
|
||||
const delay_1 = __importDefault(require("../../utils/delay"));
|
||||
let timeout;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
function watchFolders(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ folders, options, }) {
|
||||
let timeout;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
try {
|
||||
const dirs = folders;
|
||||
console.log(`Now handling ${dirs.length} Directories`);
|
||||
@ -112,8 +112,8 @@ function sync({ options, dirs, dirPath, init }) {
|
||||
cmdArray.push("--delete");
|
||||
}
|
||||
if ((_a = options === null || options === void 0 ? void 0 : options.include) === null || _a === void 0 ? void 0 : _a[0]) {
|
||||
options.include.forEach((excl) => {
|
||||
cmdArray.push(`--include='${excl}'`);
|
||||
options.include.forEach((incl) => {
|
||||
cmdArray.push(`--include='${incl}'`);
|
||||
});
|
||||
}
|
||||
if ((_b = options === null || options === void 0 ? void 0 : options.exclude) === null || _b === void 0 ? void 0 : _b[0]) {
|
||||
|
2
dist/test/test-1/folder-1/test.js
vendored
2
dist/test/test-1/folder-1/test.js
vendored
@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const testVar = 3;
|
||||
const testVar = 35;
|
||||
|
2
dist/test/test-1/folder-2/test.js
vendored
2
dist/test/test-1/folder-2/test.js
vendored
@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const testVar = 3;
|
||||
const testVar = 35;
|
||||
|
@ -3,13 +3,14 @@ import fs from "fs";
|
||||
import delay from "../../utils/delay";
|
||||
import { SyncFilesFnParams, SyncFilesSyncFnParams } from "../../types";
|
||||
|
||||
let timeout: any;
|
||||
const UPDATE_TIMEOUT = 2000;
|
||||
|
||||
export default async function watchFiles({
|
||||
files,
|
||||
options,
|
||||
}: SyncFilesFnParams) {
|
||||
let timeout: any;
|
||||
const UPDATE_TIMEOUT = 2000;
|
||||
|
||||
try {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
|
@ -4,15 +4,16 @@ import { execSync } from "child_process";
|
||||
import delay from "../../utils/delay";
|
||||
import { SyncFoldersFnParams, SyncFoldersSyncFnParams } from "../../types";
|
||||
|
||||
let timeout: any;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
|
||||
export default async function watchFolders({
|
||||
folders,
|
||||
options,
|
||||
}: SyncFoldersFnParams) {
|
||||
let timeout: any;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
|
||||
try {
|
||||
const dirs = folders;
|
||||
const dirs = folders;
|
||||
|
||||
console.log(`Now handling ${dirs.length} Directories`);
|
||||
|
||||
@ -86,6 +87,7 @@ export default async function watchFolders({
|
||||
|
||||
fs.watch(dirPath, { recursive: true }, (evt, fileName) => {
|
||||
if (global.SYNCING) return;
|
||||
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
@ -117,8 +119,8 @@ function sync({ options, dirs, dirPath, init }: SyncFoldersSyncFnParams) {
|
||||
}
|
||||
|
||||
if (options?.include?.[0]) {
|
||||
options.include.forEach((excl) => {
|
||||
cmdArray.push(`--include='${excl}'`);
|
||||
options.include.forEach((incl) => {
|
||||
cmdArray.push(`--include='${incl}'`);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/turbosync",
|
||||
"version": "1.0.6",
|
||||
"version": "1.0.7",
|
||||
"module": "dist/index.js",
|
||||
"scripts": {
|
||||
"start": "node dist/index.js",
|
||||
|
Loading…
Reference in New Issue
Block a user