fix: 🚑 logging to file causing problems with starting server
This commit is contained in:
parent
f6fe993a78
commit
8b95ef7de2
5 changed files with 58 additions and 29 deletions
|
|
@ -33,37 +33,63 @@ app.add_middleware(
|
|||
|
||||
@app.get("/health")
|
||||
def health():
|
||||
print("Testing")
|
||||
print("Health check")
|
||||
return {"status": "ok"}
|
||||
|
||||
|
||||
# add cli arg for server port
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-p", "--port", help="server port",
|
||||
type=int, default=65432)
|
||||
args = parser.parse_args()
|
||||
class Logger(object):
|
||||
def __init__(self, log_file: str):
|
||||
self.terminal = sys.stdout
|
||||
self.log = open(log_file, "a")
|
||||
|
||||
log_path = getLogFilePath()
|
||||
LOG_CONFIG = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'file': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': log_path,
|
||||
def write(self, message):
|
||||
self.terminal.write(message)
|
||||
self.log.write(message)
|
||||
|
||||
def flush(self):
|
||||
# this flush method is needed for python 3 compatibility.
|
||||
# this handles the flush command by doing nothing.
|
||||
# you might want to specify some extra behavior here.
|
||||
pass
|
||||
|
||||
def isatty(self):
|
||||
return False
|
||||
|
||||
|
||||
def setup_logging():
|
||||
log_path = getLogFilePath()
|
||||
LOG_CONFIG = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'file': {
|
||||
'level': 'DEBUG',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': log_path,
|
||||
},
|
||||
},
|
||||
},
|
||||
'root': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['file']
|
||||
'root': {
|
||||
'level': 'DEBUG',
|
||||
'handlers': ['file']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print(f"Log path: {log_path}")
|
||||
sys.stdout = open(log_path, "a")
|
||||
sys.stderr = open(log_path, "a")
|
||||
print("Testing logs")
|
||||
logger = Logger(log_path)
|
||||
print(f"Log path: {log_path}")
|
||||
# sys.stdout = logger
|
||||
# sys.stderr = logger
|
||||
print("Testing logs")
|
||||
|
||||
|
||||
try:
|
||||
# add cli arg for server port
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("-p", "--port", help="server port",
|
||||
type=int, default=65432)
|
||||
args = parser.parse_args()
|
||||
except Exception as e:
|
||||
print("Error parsing command line arguments: ", e)
|
||||
raise e
|
||||
|
||||
|
||||
def run_server():
|
||||
|
|
@ -102,6 +128,7 @@ atexit.register(cleanup)
|
|||
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
# Uncomment to get CPU usage reports
|
||||
# import threading
|
||||
|
||||
# def cpu_usage_loop():
|
||||
|
|
@ -112,6 +139,7 @@ if __name__ == "__main__":
|
|||
# cpu_thread = threading.Thread(target=cpu_usage_loop)
|
||||
# cpu_thread.start()
|
||||
|
||||
setup_logging()
|
||||
run_server()
|
||||
except Exception as e:
|
||||
print("Error starting Continue server: ", e)
|
||||
|
|
|
|||
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.0.215",
|
||||
"version": "0.0.216",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.0.215",
|
||||
"version": "0.0.216",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"displayName": "Continue",
|
||||
"pricing": "Free",
|
||||
"description": "The open-source coding autopilot",
|
||||
"version": "0.0.215",
|
||||
"version": "0.0.216",
|
||||
"publisher": "Continue",
|
||||
"engines": {
|
||||
"vscode": "^1.67.0"
|
||||
|
|
|
|||
|
|
@ -463,9 +463,8 @@ export async function startContinuePythonServer() {
|
|||
|
||||
const command = `cd "${serverPath()}" && ${activateCmd} && cd .. && ${pythonCmd} -m server.run_continue_server`;
|
||||
|
||||
console.log("Starting Continue python server...");
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
console.log("Starting Continue python server...");
|
||||
try {
|
||||
const child = spawn(command, {
|
||||
shell: true,
|
||||
|
|
|
|||
|
|
@ -62,9 +62,11 @@ class IdeProtocolClient {
|
|||
this._lastReloadTime = Math.min(2 * this._lastReloadTime, 5000);
|
||||
};
|
||||
messenger.onOpen(() => {
|
||||
console.log("IDE protocol websocket opened");
|
||||
this._reconnectionTimeouts.forEach((to) => clearTimeout(to));
|
||||
});
|
||||
messenger.onClose(() => {
|
||||
console.log("IDE protocol websocket closed");
|
||||
reconnect();
|
||||
});
|
||||
messenger.onError(() => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue