log to console as well as file
This commit is contained in:
parent
7226980fb6
commit
3d0a9b477b
1 changed files with 18 additions and 21 deletions
|
@ -13,18 +13,16 @@ require('@electron/remote/main').initialize()
|
||||||
const store = new Store()
|
const store = new Store()
|
||||||
let tray: Tray | null = null
|
let tray: Tray | null = null
|
||||||
|
|
||||||
const logFile = new winston.transports.File({
|
const logger = winston.createLogger({
|
||||||
|
transports: [
|
||||||
|
new winston.transports.Console(),
|
||||||
|
new winston.transports.File({
|
||||||
filename: path.join(app.getPath('home'), '.ollama', 'logs', 'server.log'),
|
filename: path.join(app.getPath('home'), '.ollama', 'logs', 'server.log'),
|
||||||
maxsize: 1024 * 1024 * 20,
|
maxsize: 1024 * 1024 * 20,
|
||||||
maxFiles: 5,
|
maxFiles: 5,
|
||||||
});
|
}),
|
||||||
|
],
|
||||||
const logger = winston.createLogger({
|
format: winston.format.printf(info => `${info.message}`),
|
||||||
transports: [logFile],
|
|
||||||
format: winston.format.combine(
|
|
||||||
winston.format.timestamp(),
|
|
||||||
winston.format.printf(info => `${info.timestamp} ${info.level}: ${info.message}`)
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const SingleInstanceLock = app.requestSingleInstanceLock()
|
const SingleInstanceLock = app.requestSingleInstanceLock()
|
||||||
|
@ -59,22 +57,22 @@ function server() {
|
||||||
? path.join(process.resourcesPath, 'ollama')
|
? path.join(process.resourcesPath, 'ollama')
|
||||||
: path.resolve(process.cwd(), '..', 'ollama')
|
: path.resolve(process.cwd(), '..', 'ollama')
|
||||||
|
|
||||||
const proc = spawn(binary, ['serve'])
|
const proc = spawn(binary, ['serve'], { cwd: path.dirname(binary) })
|
||||||
proc.stdout.on('data', data => {
|
proc.stdout.on('data', data => {
|
||||||
logger.info(`server: ${data.toString()}`)
|
logger.info(`server: ${data.toString()}`)
|
||||||
})
|
})
|
||||||
proc.stderr.on('data', data => {
|
proc.stderr.on('data', data => {
|
||||||
logger.error(`server: ${data.toString()}`)
|
logger.info(`server: ${data.toString()}`)
|
||||||
})
|
})
|
||||||
|
|
||||||
proc.on('exit', () => {
|
proc.on('exit', () => {
|
||||||
logger.info('Restarting the server...');
|
logger.info('Restarting the server...')
|
||||||
server();
|
server()
|
||||||
})
|
})
|
||||||
|
|
||||||
proc.on('disconnect', () => {
|
proc.on('disconnect', () => {
|
||||||
logger.info('Server disconnected. Reconnecting...');
|
logger.info('Server disconnected. Reconnecting...')
|
||||||
server();
|
server()
|
||||||
})
|
})
|
||||||
|
|
||||||
process.on('exit', () => {
|
process.on('exit', () => {
|
||||||
|
@ -82,7 +80,6 @@ function server() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function installCLI() {
|
function installCLI() {
|
||||||
const symlinkPath = '/usr/local/bin/ollama'
|
const symlinkPath = '/usr/local/bin/ollama'
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue