mirror of
https://github.com/sasjs/server.git
synced 2026-01-17 10:50:05 +00:00
chore: replace env variable RSCRIPT_PATH with R_PATH
This commit is contained in:
@@ -66,7 +66,7 @@ MODE=
|
|||||||
|
|
||||||
# A comma separated string that defines the available runTimes.
|
# A comma separated string that defines the available runTimes.
|
||||||
# Priority is given to the runtime that comes first in the string.
|
# Priority is given to the runtime that comes first in the string.
|
||||||
# Possible options at the moment are sas and js
|
# Possible options at the moment are sas, js, py and r
|
||||||
|
|
||||||
# This string sets the priority of the available analytic runtimes
|
# This string sets the priority of the available analytic runtimes
|
||||||
# Valid runtimes are SAS (sas), JavaScript (js), Python (py) and R (r)
|
# Valid runtimes are SAS (sas), JavaScript (js), Python (py) and R (r)
|
||||||
@@ -85,8 +85,8 @@ NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node
|
|||||||
# Path to Python executable
|
# Path to Python executable
|
||||||
PYTHON_PATH=/usr/bin/python
|
PYTHON_PATH=/usr/bin/python
|
||||||
|
|
||||||
# Path to Rscript
|
# Path to R executable
|
||||||
RSCRIPT_PATH=/usr/bin/Rscript
|
R_PATH=/usr/bin/Rscript
|
||||||
|
|
||||||
# Path to working directory
|
# Path to working directory
|
||||||
# This location is for SAS WORK, staged files, DRIVE, configuration etc
|
# This location is for SAS WORK, staged files, DRIVE, configuration etc
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ RUN_TIMES=[sas,js,py | js,py | sas | sas,js] default considered as sas
|
|||||||
SAS_PATH=/opt/sas/sas9/SASHome/SASFoundation/9.4/sas
|
SAS_PATH=/opt/sas/sas9/SASHome/SASFoundation/9.4/sas
|
||||||
NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node
|
NODE_PATH=~/.nvm/versions/node/v16.14.0/bin/node
|
||||||
PYTHON_PATH=/usr/bin/python
|
PYTHON_PATH=/usr/bin/python
|
||||||
RSCRIPT_PATH=/usr/bin/Rscript
|
R_PATH=/usr/bin/Rscript
|
||||||
|
|
||||||
SASJS_ROOT=./sasjs_root
|
SASJS_ROOT=./sasjs_root
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ export const processProgram = async (
|
|||||||
otherArgs
|
otherArgs
|
||||||
)
|
)
|
||||||
codePath = path.join(session.path, 'code.r')
|
codePath = path.join(session.path, 'code.r')
|
||||||
executablePath = process.rscriptLoc!
|
executablePath = process.rLoc!
|
||||||
|
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
|
|||||||
2
api/src/types/system/process.d.ts
vendored
2
api/src/types/system/process.d.ts
vendored
@@ -3,7 +3,7 @@ declare namespace NodeJS {
|
|||||||
sasLoc?: string
|
sasLoc?: string
|
||||||
nodeLoc?: string
|
nodeLoc?: string
|
||||||
pythonLoc?: string
|
pythonLoc?: string
|
||||||
rscriptLoc?: string
|
rLoc?: string
|
||||||
driveLoc: string
|
driveLoc: string
|
||||||
logsLoc: string
|
logsLoc: string
|
||||||
logsUUID: string
|
logsUUID: string
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import { createFolder, fileExists, folderExists, isWindows } from '@sasjs/utils'
|
|||||||
import { RunTimeType } from './verifyEnvVariables'
|
import { RunTimeType } from './verifyEnvVariables'
|
||||||
|
|
||||||
export const getDesktopFields = async () => {
|
export const getDesktopFields = async () => {
|
||||||
const { SAS_PATH, NODE_PATH, PYTHON_PATH, RSCRIPT_PATH } = process.env
|
const { SAS_PATH, NODE_PATH, PYTHON_PATH, R_PATH } = process.env
|
||||||
|
|
||||||
let sasLoc, nodeLoc, pythonLoc, rscriptLoc
|
let sasLoc, nodeLoc, pythonLoc, rLoc
|
||||||
|
|
||||||
if (process.runTimes.includes(RunTimeType.SAS)) {
|
if (process.runTimes.includes(RunTimeType.SAS)) {
|
||||||
sasLoc = SAS_PATH ?? (await getSASLocation())
|
sasLoc = SAS_PATH ?? (await getSASLocation())
|
||||||
@@ -21,10 +21,10 @@ export const getDesktopFields = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.runTimes.includes(RunTimeType.R)) {
|
if (process.runTimes.includes(RunTimeType.R)) {
|
||||||
rscriptLoc = RSCRIPT_PATH ?? (await getRScriptLocation())
|
rLoc = R_PATH ?? (await getRLocation())
|
||||||
}
|
}
|
||||||
|
|
||||||
return { sasLoc, nodeLoc, pythonLoc, rscriptLoc }
|
return { sasLoc, nodeLoc, pythonLoc, rLoc }
|
||||||
}
|
}
|
||||||
|
|
||||||
const getDriveLocation = async (): Promise<string> => {
|
const getDriveLocation = async (): Promise<string> => {
|
||||||
@@ -122,9 +122,9 @@ const getPythonLocation = async (): Promise<string> => {
|
|||||||
return targetName
|
return targetName
|
||||||
}
|
}
|
||||||
|
|
||||||
const getRScriptLocation = async (): Promise<string> => {
|
const getRLocation = async (): Promise<string> => {
|
||||||
const validator = async (filePath: string) => {
|
const validator = async (filePath: string) => {
|
||||||
if (!filePath) return 'Path to RScript executable is required.'
|
if (!filePath) return 'Path to R executable is required.'
|
||||||
|
|
||||||
if (!(await fileExists(filePath))) {
|
if (!(await fileExists(filePath))) {
|
||||||
return 'No file found at provided path.'
|
return 'No file found at provided path.'
|
||||||
@@ -136,7 +136,7 @@ const getRScriptLocation = async (): Promise<string> => {
|
|||||||
const defaultLocation = isWindows() ? 'C:\\Rscript' : '/usr/bin/Rscript'
|
const defaultLocation = isWindows() ? 'C:\\Rscript' : '/usr/bin/Rscript'
|
||||||
|
|
||||||
const targetName = await getString(
|
const targetName = await getString(
|
||||||
'Please enter full path to a Rscript executable: ',
|
'Please enter full path to a R executable: ',
|
||||||
validator,
|
validator,
|
||||||
defaultLocation
|
defaultLocation
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -29,14 +29,14 @@ export const setProcessVariables = async () => {
|
|||||||
process.sasLoc = process.env.SAS_PATH
|
process.sasLoc = process.env.SAS_PATH
|
||||||
process.nodeLoc = process.env.NODE_PATH
|
process.nodeLoc = process.env.NODE_PATH
|
||||||
process.pythonLoc = process.env.PYTHON_PATH
|
process.pythonLoc = process.env.PYTHON_PATH
|
||||||
process.rscriptLoc = process.env.RSCRIPT_PATH
|
process.rLoc = process.env.R_PATH
|
||||||
} else {
|
} else {
|
||||||
const { sasLoc, nodeLoc, pythonLoc, rscriptLoc } = await getDesktopFields()
|
const { sasLoc, nodeLoc, pythonLoc, rLoc } = await getDesktopFields()
|
||||||
|
|
||||||
process.sasLoc = sasLoc
|
process.sasLoc = sasLoc
|
||||||
process.nodeLoc = nodeLoc
|
process.nodeLoc = nodeLoc
|
||||||
process.pythonLoc = pythonLoc
|
process.pythonLoc = pythonLoc
|
||||||
process.rscriptLoc = rscriptLoc
|
process.rLoc = rLoc
|
||||||
}
|
}
|
||||||
|
|
||||||
const { SASJS_ROOT } = process.env
|
const { SASJS_ROOT } = process.env
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ const verifyRUN_TIMES = (): string[] => {
|
|||||||
|
|
||||||
const verifyExecutablePaths = () => {
|
const verifyExecutablePaths = () => {
|
||||||
const errors: string[] = []
|
const errors: string[] = []
|
||||||
const { RUN_TIMES, SAS_PATH, NODE_PATH, PYTHON_PATH, RSCRIPT_PATH, MODE } =
|
const { RUN_TIMES, SAS_PATH, NODE_PATH, PYTHON_PATH, R_PATH, MODE } =
|
||||||
process.env
|
process.env
|
||||||
|
|
||||||
if (MODE === ModeType.Server) {
|
if (MODE === ModeType.Server) {
|
||||||
@@ -272,8 +272,8 @@ const verifyExecutablePaths = () => {
|
|||||||
errors.push(`- PYTHON_PATH is required for ${RunTimeType.PY} run time`)
|
errors.push(`- PYTHON_PATH is required for ${RunTimeType.PY} run time`)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (runTimes?.includes(RunTimeType.R) && !RSCRIPT_PATH) {
|
if (runTimes?.includes(RunTimeType.R) && !R_PATH) {
|
||||||
errors.push(`- RSCRIPT_PATH is required for ${RunTimeType.R} run time`)
|
errors.push(`- R_PATH is required for ${RunTimeType.R} run time`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user