Git Komut Rehberi & Terminal Asistanı
Sıfırdan Yeni Bir Depo Başlatın:
Mevcut Bir Git Deposu veya Klasörü Gönderin:
Hataları Geri Alma, İptal & Temizlik:
Son commit'i geri al (yapılan değişiklikleri korur):
git reset --soft HEAD~1
Yapılan yerel değişiklikleri iptal et (çalışma ağacını temizler):
git restore .
Takip edilmeyen gereksiz dosyaları sil:
git clean -fd
Değişiklikleri geçici sakla ve geri getir (stash):
git stash git stash pop
Dal (Branch) ve Sürüm Etiketleri:
Yeni dal aç ve geçiş yap:
git checkout -b yeni-ozellik git push -u origin yeni-ozellik
Sürüm etiketi (tag) oluştur ve gönder:
git tag -a v1.0.0 -m "Sürüm 1.0.0" git push origin --tags
86 lines
2.0 KiB
JavaScript
86 lines
2.0 KiB
JavaScript
import { spawn } from "node:child_process";
|
|
import net from "node:net";
|
|
|
|
const parsePort = (value, fallback, name) => {
|
|
const port = Number.parseInt(value ?? "", 10);
|
|
if (Number.isInteger(port) && port > 0 && port <= 65_535) {
|
|
return port;
|
|
}
|
|
if (value) {
|
|
console.warn(`Ignoring invalid ${name} value "${value}"; using ${fallback}.`);
|
|
}
|
|
return fallback;
|
|
};
|
|
|
|
const appPort = parsePort(process.env.PORT, 3000, "PORT");
|
|
const legacyPort = parsePort(process.env.SKETCHFORGE_LEGACY_PORT, 80, "SKETCHFORGE_LEGACY_PORT");
|
|
const app = spawn(process.execPath, ["apps/web/server.js"], {
|
|
env: {
|
|
...process.env,
|
|
HOSTNAME: process.env.HOSTNAME || "0.0.0.0",
|
|
PORT: String(appPort),
|
|
},
|
|
stdio: "inherit",
|
|
});
|
|
|
|
let proxy;
|
|
let shuttingDown = false;
|
|
|
|
if (legacyPort !== appPort) {
|
|
proxy = net.createServer((client) => {
|
|
const upstream = net.createConnection({
|
|
host: "127.0.0.1",
|
|
port: appPort,
|
|
});
|
|
|
|
client.on("error", () => upstream.destroy());
|
|
upstream.on("error", () => client.destroy());
|
|
client.pipe(upstream);
|
|
upstream.pipe(client);
|
|
});
|
|
|
|
proxy.on("error", (error) => {
|
|
console.error(`Legacy port ${legacyPort} proxy failed:`, error);
|
|
app.kill("SIGTERM");
|
|
});
|
|
|
|
proxy.listen(legacyPort, "0.0.0.0", () => {
|
|
console.log(`Legacy Docker port ${legacyPort} forwards to SketchForge on port ${appPort}.`);
|
|
});
|
|
}
|
|
|
|
const finish = (code) => {
|
|
if (proxy?.listening) {
|
|
proxy.close(() => process.exit(code));
|
|
setTimeout(() => process.exit(code), 5_000).unref();
|
|
return;
|
|
}
|
|
process.exit(code);
|
|
};
|
|
|
|
const shutdown = (signal) => {
|
|
if (shuttingDown) {
|
|
return;
|
|
}
|
|
shuttingDown = true;
|
|
if (!app.killed) {
|
|
app.kill(signal);
|
|
}
|
|
};
|
|
|
|
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
process.on(signal, () => shutdown(signal));
|
|
}
|
|
|
|
app.on("error", (error) => {
|
|
console.error("Unable to start SketchForge:", error);
|
|
finish(1);
|
|
});
|
|
|
|
app.on("exit", (code, signal) => {
|
|
if (!shuttingDown && signal) {
|
|
console.error(`SketchForge exited from ${signal}.`);
|
|
}
|
|
finish(shuttingDown ? 0 : code ?? 1);
|
|
});
|