diff --git a/README.md b/README.md index 3aab4af..409ccc1 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,9 @@ HELMET_CSP_CONFIG_PATH=./csp.config.json # Docs: https://www.npmjs.com/package/morgan#predefined-formats LOG_FORMAT_MORGAN= +# This location is for server logs with classical UNIX logrotate behavior +LOG_LOCATION=./sasjs_root/logs + # A comma separated string that defines the available runTimes. # Priority is given to the runtime that comes first in the string. # Possible options at the moment are sas and js diff --git a/api/.env.example b/api/.env.example index dc8374c..e585aaf 100644 --- a/api/.env.example +++ b/api/.env.example @@ -20,4 +20,5 @@ NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node SASJS_ROOT=./sasjs_root -LOG_FORMAT_MORGAN=common \ No newline at end of file +LOG_FORMAT_MORGAN=common +LOG_LOCATION=./sasjs_root/logs \ No newline at end of file diff --git a/api/src/types/system/process.d.ts b/api/src/types/system/process.d.ts index d7eaf71..bf29e16 100644 --- a/api/src/types/system/process.d.ts +++ b/api/src/types/system/process.d.ts @@ -3,6 +3,7 @@ declare namespace NodeJS { sasLoc?: string nodeLoc?: string driveLoc: string + logsLoc: string sasSessionController?: import('../../controllers/internal').SASSessionController jsSessionController?: import('../../controllers/internal').JSSessionController appStreamConfig: import('../').AppStreamConfig diff --git a/api/src/utils/file.ts b/api/src/utils/file.ts index f109e0d..985f10b 100644 --- a/api/src/utils/file.ts +++ b/api/src/utils/file.ts @@ -22,6 +22,8 @@ export const getDesktopUserAutoExecPath = () => export const getSasjsRootFolder = () => process.driveLoc +export const getLogFolder = () => process.logsLoc + export const getAppStreamConfigPath = () => path.join(getSasjsRootFolder(), 'appStreamConfig.json') @@ -32,8 +34,6 @@ export const getUploadsFolder = () => path.join(getSasjsRootFolder(), 'uploads') export const getFilesFolder = () => path.join(getSasjsRootFolder(), 'files') -export const getLogFolder = () => path.join(getSasjsRootFolder(), 'logs') - export const getWeboutFolder = () => path.join(getSasjsRootFolder(), 'webouts') export const getSessionsFolder = () => diff --git a/api/src/utils/setProcessVariables.ts b/api/src/utils/setProcessVariables.ts index d1b3991..9fc3616 100644 --- a/api/src/utils/setProcessVariables.ts +++ b/api/src/utils/setProcessVariables.ts @@ -40,7 +40,16 @@ export const setProcessVariables = async () => { await createFolder(absPath) process.driveLoc = getRealPath(absPath) + const { LOG_LOCATION } = process.env + const absLogsPath = getAbsolutePath( + LOG_LOCATION ?? `sasjs_root${path.sep}logs`, + process.cwd() + ) + await createFolder(absLogsPath) + process.logsLoc = getRealPath(absLogsPath) + console.log('sasLoc: ', process.sasLoc) console.log('sasDrive: ', process.driveLoc) + console.log('sasLogs: ', process.logsLoc) console.log('runTimes: ', process.runTimes) }