cloud-ide-cide 2.0.42 → 2.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cideShell.js +74 -45
- package/package.json +2 -2
- package/publishPackage.js +6 -1
package/cideShell.js
CHANGED
|
@@ -687,48 +687,73 @@ function getPidFilePath(ws) {
|
|
|
687
687
|
return path.join(process.cwd(), PID_FILE);
|
|
688
688
|
}
|
|
689
689
|
|
|
690
|
-
function
|
|
691
|
-
const file = getPidFilePath(ws);
|
|
692
|
-
fs.writeFileSync(file, JSON.stringify({ pid, command, args, timestamp: Date.now() }));
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
function loadPid(ws) {
|
|
690
|
+
function loadPids(ws) {
|
|
696
691
|
const file = getPidFilePath(ws);
|
|
697
692
|
if (fs.existsSync(file)) {
|
|
698
693
|
try {
|
|
699
|
-
|
|
694
|
+
const data = JSON.parse(fs.readFileSync(file, 'utf8'));
|
|
695
|
+
return Array.isArray(data) ? data : [data];
|
|
700
696
|
} catch {}
|
|
701
697
|
}
|
|
702
|
-
return
|
|
698
|
+
return [];
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
function savePid(ws, pid, command, args) {
|
|
702
|
+
const file = getPidFilePath(ws);
|
|
703
|
+
const pids = loadPids(ws);
|
|
704
|
+
pids.push({ pid, command, args, timestamp: Date.now() });
|
|
705
|
+
fs.writeFileSync(file, JSON.stringify(pids, null, 2));
|
|
703
706
|
}
|
|
704
707
|
|
|
705
|
-
function clearPid(ws) {
|
|
708
|
+
function clearPid(ws, pidToRemove) {
|
|
706
709
|
const file = getPidFilePath(ws);
|
|
710
|
+
let pids = loadPids(ws);
|
|
711
|
+
if (pidToRemove) {
|
|
712
|
+
pids = pids.filter(p => p.pid !== pidToRemove);
|
|
713
|
+
if (pids.length > 0) {
|
|
714
|
+
fs.writeFileSync(file, JSON.stringify(pids, null, 2));
|
|
715
|
+
return;
|
|
716
|
+
}
|
|
717
|
+
}
|
|
707
718
|
if (fs.existsSync(file)) fs.unlinkSync(file);
|
|
708
719
|
}
|
|
709
720
|
|
|
710
|
-
function killBgServer(ws) {
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
721
|
+
function killBgServer(ws, specificPid) {
|
|
722
|
+
const pids = loadPids(ws);
|
|
723
|
+
if (pids.length === 0) {
|
|
724
|
+
let fallbackPid = bgServerPid;
|
|
725
|
+
if (specificPid) fallbackPid = parseInt(specificPid, 10);
|
|
726
|
+
if (!fallbackPid) {
|
|
727
|
+
console.log('No background server PIDs tracked.');
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
pids.push({ pid: fallbackPid, command: 'unknown', args: [] });
|
|
715
731
|
}
|
|
716
|
-
|
|
717
|
-
|
|
732
|
+
|
|
733
|
+
const targets = specificPid
|
|
734
|
+
? pids.filter(p => p.pid === parseInt(specificPid, 10))
|
|
735
|
+
: pids;
|
|
736
|
+
|
|
737
|
+
if (targets.length === 0) {
|
|
738
|
+
console.log(`PID ${specificPid} not found in tracked background processes.`);
|
|
718
739
|
return;
|
|
719
740
|
}
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
process.
|
|
741
|
+
|
|
742
|
+
for (const processInfo of targets) {
|
|
743
|
+
const targetPid = processInfo.pid;
|
|
744
|
+
try {
|
|
745
|
+
if (process.platform === 'win32') {
|
|
746
|
+
execSync(`taskkill /PID ${targetPid} /T /F`, { stdio: 'ignore', shell: true });
|
|
747
|
+
} else {
|
|
748
|
+
process.kill(-targetPid, 'SIGTERM');
|
|
749
|
+
}
|
|
750
|
+
console.log(`Stopped process tree ${targetPid} (${processInfo.command} ${processInfo.args.join(' ')})`);
|
|
751
|
+
} catch (e) {
|
|
752
|
+
console.error(`Stop failed or process ${targetPid} already killed: ${e.message}`);
|
|
725
753
|
}
|
|
726
|
-
|
|
727
|
-
} catch (e) {
|
|
728
|
-
console.error(`Stop failed or process already killed: ${e.message}`);
|
|
754
|
+
clearPid(ws, targetPid);
|
|
729
755
|
}
|
|
730
|
-
bgServerPid = null;
|
|
731
|
-
clearPid(ws);
|
|
756
|
+
if (!specificPid) bgServerPid = null;
|
|
732
757
|
}
|
|
733
758
|
|
|
734
759
|
function spawnBg(ws, cwd, command, args) {
|
|
@@ -789,33 +814,37 @@ async function handleServer(ws, sub, rest, rl) {
|
|
|
789
814
|
return;
|
|
790
815
|
}
|
|
791
816
|
if (sub === 'status') {
|
|
792
|
-
const
|
|
793
|
-
if (
|
|
794
|
-
console.log('
|
|
817
|
+
const pids = loadPids(ws);
|
|
818
|
+
if (pids.length === 0) {
|
|
819
|
+
console.log('No services are currently tracked as running in the background.');
|
|
795
820
|
return;
|
|
796
821
|
}
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
822
|
+
console.log(`Found ${pids.length} tracked background service(s):\n`);
|
|
823
|
+
|
|
824
|
+
for (const processInfo of pids) {
|
|
825
|
+
let isRunning = false;
|
|
826
|
+
try {
|
|
827
|
+
if (process.platform === 'win32') {
|
|
828
|
+
const out = execSync(`tasklist /FI "PID eq ${processInfo.pid}"`, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'ignore'] });
|
|
829
|
+
isRunning = out.includes(processInfo.pid.toString());
|
|
830
|
+
} else {
|
|
831
|
+
process.kill(processInfo.pid, 0);
|
|
832
|
+
isRunning = true;
|
|
833
|
+
}
|
|
834
|
+
} catch {
|
|
835
|
+
isRunning = false;
|
|
836
|
+
}
|
|
837
|
+
if (isRunning) {
|
|
838
|
+
console.log(`[🏃 RUNNING] PID: ${processInfo.pid} | Command: ${processInfo.command} ${processInfo.args.join(' ')}`);
|
|
802
839
|
} else {
|
|
803
|
-
|
|
804
|
-
|
|
840
|
+
console.log(`[❌ STALE] PID: ${processInfo.pid} | Command: ${processInfo.command} ${processInfo.args.join(' ')} (No longer running)`);
|
|
841
|
+
clearPid(ws, processInfo.pid);
|
|
805
842
|
}
|
|
806
|
-
} catch {
|
|
807
|
-
isRunning = false;
|
|
808
|
-
}
|
|
809
|
-
if (isRunning) {
|
|
810
|
-
console.log(`Server is RUNNING (PID: ${processInfo.pid}, Command: ${processInfo.command} ${processInfo.args.join(' ')})`);
|
|
811
|
-
} else {
|
|
812
|
-
console.log(`Server was tracked as PID: ${processInfo.pid} but appears to be dead now.`);
|
|
813
|
-
clearPid(ws);
|
|
814
843
|
}
|
|
815
844
|
return;
|
|
816
845
|
}
|
|
817
846
|
if (sub === 'stop') {
|
|
818
|
-
killBgServer(ws);
|
|
847
|
+
killBgServer(ws, rest[0]);
|
|
819
848
|
return;
|
|
820
849
|
}
|
|
821
850
|
console.error('Usage: server build | start | dev | stop | status | init | listener start|stop|status|restart');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cloud-ide-cide",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.43",
|
|
4
4
|
"description": "Cloud IDE CLI — create, build, publish, upload and deploy Cloud IDE projects.",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"bin": {
|
|
@@ -50,4 +50,4 @@
|
|
|
50
50
|
"author": "Ankush Shivlal Bhure",
|
|
51
51
|
"license": "ISC",
|
|
52
52
|
"repository": {}
|
|
53
|
-
}
|
|
53
|
+
}
|
package/publishPackage.js
CHANGED
|
@@ -834,7 +834,9 @@ async function publishPackage(options = {}) {
|
|
|
834
834
|
const originalCwd = process.cwd();
|
|
835
835
|
|
|
836
836
|
try {
|
|
837
|
-
if (
|
|
837
|
+
if (rl) rl.pause();
|
|
838
|
+
try {
|
|
839
|
+
if (entry.kind === 'angular-lib') {
|
|
838
840
|
if (cide.templete !== 'angular') {
|
|
839
841
|
console.warn(' Warning: cide.templete is not "angular"; still running ng build.');
|
|
840
842
|
}
|
|
@@ -902,6 +904,9 @@ async function publishPackage(options = {}) {
|
|
|
902
904
|
}
|
|
903
905
|
publishOk++;
|
|
904
906
|
stepComplete = true;
|
|
907
|
+
} finally {
|
|
908
|
+
if (rl) rl.resume();
|
|
909
|
+
}
|
|
905
910
|
} catch (err) {
|
|
906
911
|
console.error(` ❌ Failed: ${err.message}`);
|
|
907
912
|
process.chdir(originalCwd);
|