mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 03:34:35 +00:00
chore: reverted 4 commits related to copying exe scripts
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,4 +9,3 @@ build/
|
|||||||
certificates/
|
certificates/
|
||||||
executables/
|
executables/
|
||||||
.env
|
.env
|
||||||
sas
|
|
||||||
@@ -4,7 +4,6 @@ COPY ["package.json","package-lock.json", "./"]
|
|||||||
RUN npm ci
|
RUN npm ci
|
||||||
COPY ./api .
|
COPY ./api .
|
||||||
COPY ./certificates ../certificates
|
COPY ./certificates ../certificates
|
||||||
COPY ./sas_exe ../sas_exe
|
|
||||||
# RUN chown -R node /usr/server/api
|
# RUN chown -R node /usr/server/api
|
||||||
# USER node
|
# USER node
|
||||||
CMD ["npm","start"]
|
CMD ["npm","start"]
|
||||||
|
|||||||
@@ -79,6 +79,7 @@
|
|||||||
"typescript": "^4.3.2"
|
"typescript": "^4.3.2"
|
||||||
},
|
},
|
||||||
"configuration": {
|
"configuration": {
|
||||||
"sasPath": "/opt/sas/sas9/SASHome/SASFoundation/9.4/sas"
|
"sasPath": "/opt/sas/sas9/SASHome/SASFoundation/9.4/sas",
|
||||||
|
"sasJsPort": 5000
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@ import cors from 'cors'
|
|||||||
|
|
||||||
import webRouter from './routes/web'
|
import webRouter from './routes/web'
|
||||||
import apiRouter from './routes/api'
|
import apiRouter from './routes/api'
|
||||||
import { connectDB, getWebBuildFolderPath } from './utils'
|
import { getWebBuildFolderPath } from './utils'
|
||||||
|
import { connectDB } from './routes/api/auth'
|
||||||
|
|
||||||
dotenv.config()
|
dotenv.config()
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import path from 'path'
|
import path from 'path'
|
||||||
import { Session } from '../../types'
|
import { Session } from '../../types'
|
||||||
|
import { configuration } from '../../../package.json'
|
||||||
import { promisify } from 'util'
|
import { promisify } from 'util'
|
||||||
import { execFile } from 'child_process'
|
import { execFile } from 'child_process'
|
||||||
import { getTmpSessionsFolderPath, generateUniqueFileName } from '../../utils'
|
import { getTmpSessionsFolderPath, generateUniqueFileName } from '../../utils'
|
||||||
@@ -64,8 +65,8 @@ export class SessionController {
|
|||||||
// update the session array to say that it is currently running
|
// update the session array to say that it is currently running
|
||||||
// however we also need a promise so that we can update the
|
// however we also need a promise so that we can update the
|
||||||
// session array to say that it has (eventually) finished.
|
// session array to say that it has (eventually) finished.
|
||||||
|
const sasLoc = process.sasLoc ?? configuration.sasPath
|
||||||
execFilePromise(process.sasLoc, [
|
execFilePromise(sasLoc, [
|
||||||
'-SYSIN',
|
'-SYSIN',
|
||||||
codePath,
|
codePath,
|
||||||
'-LOG',
|
'-LOG',
|
||||||
@@ -83,7 +84,7 @@ export class SessionController {
|
|||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
session.completed = true
|
session.completed = true
|
||||||
session.crashed = err.toString()
|
session.crashed = err.toString()
|
||||||
console.log('session crashed', session.id)
|
console.log('session crashed', session.id, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
// we have a triggered session - add to array
|
// we have a triggered session - add to array
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import express from 'express'
|
import express from 'express'
|
||||||
|
import mongoose from 'mongoose'
|
||||||
|
|
||||||
import { AuthController } from '../../controllers/'
|
import { AuthController } from '../../controllers/'
|
||||||
import Client from '../../model/Client'
|
import Client from '../../model/Client'
|
||||||
@@ -27,6 +28,32 @@ export const populateClients = async () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const connectDB = async () => {
|
||||||
|
const { MODE } = process.env
|
||||||
|
if (MODE?.trim() !== 'server') {
|
||||||
|
console.log('Running in Destop Mode, no DB to connect.')
|
||||||
|
|
||||||
|
const { sasLoc, driveLoc } = await getDesktopFields()
|
||||||
|
|
||||||
|
process.sasLoc = sasLoc
|
||||||
|
process.driveLoc = driveLoc
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// NOTE: when exporting app.js as agent for supertest
|
||||||
|
// we should exlcude connecting to the real database
|
||||||
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
|
mongoose.connect(process.env.DB_CONNECT as string, async (err) => {
|
||||||
|
if (err) throw err
|
||||||
|
|
||||||
|
console.log('Connected to db!')
|
||||||
|
|
||||||
|
await populateClients()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
authRouter.post('/authorize', async (req, res) => {
|
authRouter.post('/authorize', async (req, res) => {
|
||||||
const { error, value: body } = authorizeValidation(req.body)
|
const { error, value: body } = authorizeValidation(req.body)
|
||||||
if (error) return res.status(400).send(error.details[0].message)
|
if (error) return res.status(400).send(error.details[0].message)
|
||||||
|
|||||||
2
api/src/types/Process.d.ts
vendored
2
api/src/types/Process.d.ts
vendored
@@ -1,6 +1,6 @@
|
|||||||
declare namespace NodeJS {
|
declare namespace NodeJS {
|
||||||
export interface Process {
|
export interface Process {
|
||||||
sasLoc: string
|
sasLoc?: string
|
||||||
driveLoc?: string
|
driveLoc?: string
|
||||||
sessionController?: import('../controllers/internal').SessionController
|
sessionController?: import('../controllers/internal').SessionController
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
import path from 'path'
|
|
||||||
import mongoose from 'mongoose'
|
|
||||||
import { configuration } from '../../package.json'
|
|
||||||
import { getDesktopFields } from '.'
|
|
||||||
import { populateClients } from '../routes/api/auth'
|
|
||||||
import { fileExists } from '@sasjs/utils'
|
|
||||||
|
|
||||||
export const connectDB = async () => {
|
|
||||||
const { MODE } = process.env
|
|
||||||
if (MODE?.trim() !== 'server') {
|
|
||||||
console.log('Running in Destop Mode, no DB to connect.')
|
|
||||||
|
|
||||||
const { sasLoc, driveLoc } = await getDesktopFields()
|
|
||||||
|
|
||||||
process.sasLoc = sasLoc
|
|
||||||
process.driveLoc = driveLoc
|
|
||||||
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
const { SAS_EXEC } = process.env
|
|
||||||
process.sasLoc = SAS_EXEC
|
|
||||||
? path.join(__dirname, '..', '..', '..', SAS_EXEC)
|
|
||||||
: configuration.sasPath
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('SAS_EXEC: ', process.sasLoc)
|
|
||||||
console.log('SAS_EXEC Exists: ', await fileExists(process.sasLoc))
|
|
||||||
|
|
||||||
// NOTE: when exporting app.js as agent for supertest
|
|
||||||
// we should exlcude connecting to the real database
|
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
|
||||||
mongoose.connect(process.env.DB_CONNECT as string, async (err) => {
|
|
||||||
if (err) throw err
|
|
||||||
|
|
||||||
console.log('Connected to db!')
|
|
||||||
|
|
||||||
await populateClients()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
export * from './connectDB'
|
|
||||||
export * from './file'
|
export * from './file'
|
||||||
export * from './generateAccessToken'
|
export * from './generateAccessToken'
|
||||||
export * from './generateAuthCode'
|
export * from './generateAuthCode'
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ services:
|
|||||||
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
|
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
|
||||||
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
|
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
|
||||||
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
||||||
SAS_EXEC: ${SAS_EXEC}
|
|
||||||
expose:
|
expose:
|
||||||
- ${PORT_API}
|
- ${PORT_API}
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ services:
|
|||||||
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
|
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
|
||||||
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
|
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
|
||||||
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
DB_CONNECT: mongodb://mongodb:27017/sasjs
|
||||||
SAS_EXEC: ${SAS_EXEC}
|
|
||||||
expose:
|
expose:
|
||||||
- ${PORT_API}
|
- ${PORT_API}
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
sasjsPath=$(grep sasPath ./api/package.json | sed 's/.*"sasPath": "\(.*\)".*/\1/')
|
|
||||||
|
|
||||||
if [ -z "$sasjsPath" ]
|
|
||||||
then
|
|
||||||
echo "Please enter path to SAS executable:"
|
|
||||||
read sasjsPath
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -e $sasjsPath ]
|
|
||||||
then
|
|
||||||
echo "Using sas executable:" \"$sasjsPath\"
|
|
||||||
else
|
|
||||||
echo "No file present at:" \"$sasjsPath\"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# copy sas executable to current directory, because docker cannot copy files outside of context.
|
|
||||||
rm -rf sas_exe
|
|
||||||
mkdir sas_exe
|
|
||||||
cp $sasjsPath ./sas_exe/sas
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
# Copy SAS executable from source to current folder to make it available to docker
|
|
||||||
./dockerSASexe.sh
|
|
||||||
|
|
||||||
# Run docker-compose with default docker compose file i.e. docker-compose.yml
|
|
||||||
SAS_EXEC=sas_exe/sas docker-compose up --build -d
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
|
|
||||||
# Copy SAS executable from source to current folder to make it available to docker
|
|
||||||
./dockerSASexe.sh
|
|
||||||
|
|
||||||
# Build & Run docker-compose with docker compose file i.e. docker-compose.prod.yml
|
|
||||||
SAS_EXEC=sas_exe/sas docker-compose -f docker-compose.prod.yml up --build -d
|
|
||||||
Reference in New Issue
Block a user