This commit is contained in:
Benjamin Toby 2025-07-11 06:49:06 +01:00
parent 68c1074de1
commit 37a314273a
8 changed files with 52 additions and 16 deletions

View File

@ -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
```

View File

@ -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];

View File

@ -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]) {

View File

@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const testVar = 3;
const testVar = 35;

View File

@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const testVar = 3;
const testVar = 35;

View File

@ -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];

View File

@ -4,13 +4,14 @@ 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;
@ -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}'`);
});
}

View File

@ -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",