1
0
mirror of https://github.com/sasjs/server.git synced 2025-12-10 19:34:34 +00:00

chore: reverted 4 commits related to copying exe scripts

This commit is contained in:
Saad Jutt
2021-11-17 07:49:02 +05:00
parent b3147ec680
commit 455367f10a
14 changed files with 36 additions and 84 deletions

1
.gitignore vendored
View File

@@ -9,4 +9,3 @@ build/
certificates/
executables/
.env
sas

View File

@@ -4,7 +4,6 @@ COPY ["package.json","package-lock.json", "./"]
RUN npm ci
COPY ./api .
COPY ./certificates ../certificates
COPY ./sas_exe ../sas_exe
# RUN chown -R node /usr/server/api
# USER node
CMD ["npm","start"]

View File

@@ -79,6 +79,7 @@
"typescript": "^4.3.2"
},
"configuration": {
"sasPath": "/opt/sas/sas9/SASHome/SASFoundation/9.4/sas"
"sasPath": "/opt/sas/sas9/SASHome/SASFoundation/9.4/sas",
"sasJsPort": 5000
}
}

View File

@@ -6,7 +6,8 @@ import cors from 'cors'
import webRouter from './routes/web'
import apiRouter from './routes/api'
import { connectDB, getWebBuildFolderPath } from './utils'
import { getWebBuildFolderPath } from './utils'
import { connectDB } from './routes/api/auth'
dotenv.config()

View File

@@ -1,5 +1,6 @@
import path from 'path'
import { Session } from '../../types'
import { configuration } from '../../../package.json'
import { promisify } from 'util'
import { execFile } from 'child_process'
import { getTmpSessionsFolderPath, generateUniqueFileName } from '../../utils'
@@ -64,8 +65,8 @@ export class SessionController {
// update the session array to say that it is currently running
// however we also need a promise so that we can update the
// session array to say that it has (eventually) finished.
execFilePromise(process.sasLoc, [
const sasLoc = process.sasLoc ?? configuration.sasPath
execFilePromise(sasLoc, [
'-SYSIN',
codePath,
'-LOG',
@@ -83,7 +84,7 @@ export class SessionController {
.catch((err) => {
session.completed = true
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

View File

@@ -1,4 +1,5 @@
import express from 'express'
import mongoose from 'mongoose'
import { AuthController } from '../../controllers/'
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) => {
const { error, value: body } = authorizeValidation(req.body)
if (error) return res.status(400).send(error.details[0].message)

View File

@@ -1,6 +1,6 @@
declare namespace NodeJS {
export interface Process {
sasLoc: string
sasLoc?: string
driveLoc?: string
sessionController?: import('../controllers/internal').SessionController
}

View File

@@ -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()
})
}
}

View File

@@ -1,4 +1,3 @@
export * from './connectDB'
export * from './file'
export * from './generateAccessToken'
export * from './generateAuthCode'

View File

@@ -14,7 +14,6 @@ services:
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
DB_CONNECT: mongodb://mongodb:27017/sasjs
SAS_EXEC: ${SAS_EXEC}
expose:
- ${PORT_API}
ports:

View File

@@ -15,7 +15,6 @@ services:
REFRESH_TOKEN_SECRET: ${REFRESH_TOKEN_SECRET}
AUTH_CODE_SECRET: ${AUTH_CODE_SECRET}
DB_CONNECT: mongodb://mongodb:27017/sasjs
SAS_EXEC: ${SAS_EXEC}
expose:
- ${PORT_API}
ports:

View File

@@ -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

View File

@@ -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

View File

@@ -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