small fixes to setup
This commit is contained in:
parent
66b3a267c8
commit
bfd2f09cd6
2 changed files with 22 additions and 18 deletions
|
|
@ -36,16 +36,20 @@ def getConfigFilePath() -> str:
|
|||
path = os.path.join(getGlobalFolderPath(), "config.py")
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
|
||||
with open(path, 'r') as f:
|
||||
existing_content = f.read()
|
||||
|
||||
if not os.path.exists(path) or existing_content.strip() == "":
|
||||
if not os.path.exists(path):
|
||||
with open(path, 'w') as f:
|
||||
f.write(default_config)
|
||||
elif " continuedev.core" in existing_content:
|
||||
with open(path, 'w') as f:
|
||||
f.write(existing_content.replace(" continuedev.",
|
||||
" continuedev.src.continuedev."))
|
||||
else:
|
||||
with open(path, 'r') as f:
|
||||
existing_content = f.read()
|
||||
|
||||
if existing_content.strip() == "":
|
||||
with open(path, 'w') as f:
|
||||
f.write(default_config)
|
||||
elif " continuedev.core" in existing_content:
|
||||
with open(path, 'w') as f:
|
||||
f.write(existing_content.replace(" continuedev.",
|
||||
" continuedev.src.continuedev."))
|
||||
|
||||
return path
|
||||
|
||||
|
|
|
|||
|
|
@ -83,23 +83,23 @@ export function getExtensionVersion() {
|
|||
// Returns whether a server of the current version is already running
|
||||
async function checkOrKillRunningServer(serverUrl: string): Promise<boolean> {
|
||||
console.log("Checking if server is old version");
|
||||
const serverRunning = await checkServerRunning(serverUrl);
|
||||
// Kill the server if it is running an old version
|
||||
if (fs.existsSync(serverVersionPath())) {
|
||||
const serverVersion = fs.readFileSync(serverVersionPath(), "utf8");
|
||||
if (
|
||||
serverVersion === getExtensionVersion() &&
|
||||
(await checkServerRunning(serverUrl))
|
||||
) {
|
||||
if (serverVersion === getExtensionVersion() && serverRunning) {
|
||||
// The current version is already up and running, no need to continue
|
||||
return true;
|
||||
}
|
||||
}
|
||||
console.log("Killing old server...");
|
||||
try {
|
||||
await fkill(":65432");
|
||||
} catch (e: any) {
|
||||
if (!e.message.includes("Process doesn't exist")) {
|
||||
console.log("Failed to kill old server:", e);
|
||||
if (serverRunning) {
|
||||
console.log("Killing old server...");
|
||||
try {
|
||||
await fkill(":65432");
|
||||
} catch (e: any) {
|
||||
if (!e.message.includes("Process doesn't exist")) {
|
||||
console.log("Failed to kill old server:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue