enable clustering on server and worker services, better log output on user not found errors
This commit is contained in:
parent
b33d8ba588
commit
9d813292de
|
@ -29,7 +29,7 @@ passport.deserializeUser(async (user, done) => {
|
||||||
const user = await db.get(user._id)
|
const user = await db.get(user._id)
|
||||||
return done(null, user)
|
return done(null, user)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error("User not found", err)
|
console.error(`User not found`, err)
|
||||||
return done(null, false, { message: "User not found" })
|
return done(null, false, { message: "User not found" })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -30,7 +30,7 @@ exports.authenticate = async function (ctx, email, password, done) {
|
||||||
|
|
||||||
const dbUser = await getGlobalUserByEmail(email)
|
const dbUser = await getGlobalUserByEmail(email)
|
||||||
if (dbUser == null) {
|
if (dbUser == null) {
|
||||||
return authError(done, "User not found")
|
return authError(done, `User not found: [${email}]`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that the user is currently inactive, if this is the case throw invalid
|
// check that the user is currently inactive, if this is the case throw invalid
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
async function login() {
|
async function login() {
|
||||||
try {
|
try {
|
||||||
await auth.login({
|
await auth.login({
|
||||||
username,
|
username: username.trim(),
|
||||||
password,
|
password,
|
||||||
})
|
})
|
||||||
if ($auth?.user?.forceResetPassword) {
|
if ($auth?.user?.forceResetPassword) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ ENV BUDIBASE_ENVIRONMENT=PRODUCTION
|
||||||
# copy files and install dependencies
|
# copy files and install dependencies
|
||||||
COPY . ./
|
COPY . ./
|
||||||
RUN yarn
|
RUN yarn
|
||||||
|
RUN yarn global add pm2
|
||||||
RUN yarn build
|
RUN yarn build
|
||||||
|
|
||||||
# Install client for oracle datasource
|
# Install client for oracle datasource
|
||||||
|
@ -28,4 +29,5 @@ EXPOSE 4001
|
||||||
# due to this causing yarn to stop installing dev dependencies
|
# due to this causing yarn to stop installing dev dependencies
|
||||||
# which are actually needed to get this environment up and running
|
# which are actually needed to get this environment up and running
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
CMD ["yarn", "run:docker"]
|
ENV CLUSTER_MODE=${CLUSTER_MODE}
|
||||||
|
CMD ["./docker_run.sh"]
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
if [ -z $CLUSTER_MODE ]; then
|
||||||
|
yarn run:docker
|
||||||
|
else
|
||||||
|
yarn run:docker:cluster
|
||||||
|
fi
|
|
@ -18,6 +18,7 @@
|
||||||
"build:docker": "yarn run predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
|
"build:docker": "yarn run predocker && docker build . -t app-service --label version=$BUDIBASE_RELEASE_VERSION",
|
||||||
"build:docs": "node ./scripts/docs/generate.js open",
|
"build:docs": "node ./scripts/docs/generate.js open",
|
||||||
"run:docker": "node dist/index.js",
|
"run:docker": "node dist/index.js",
|
||||||
|
"run:docker:cluster": "pm2-runtime start pm2.js",
|
||||||
"dev:stack:up": "node scripts/dev/manage.js up",
|
"dev:stack:up": "node scripts/dev/manage.js up",
|
||||||
"dev:stack:down": "node scripts/dev/manage.js down",
|
"dev:stack:down": "node scripts/dev/manage.js down",
|
||||||
"dev:stack:nuke": "node scripts/dev/manage.js nuke",
|
"dev:stack:nuke": "node scripts/dev/manage.js nuke",
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = {
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
script: "dist/index.js",
|
||||||
|
instances: "max",
|
||||||
|
exec_mode: "cluster",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
|
@ -10,6 +10,7 @@ WORKDIR /app
|
||||||
# copy files and install dependencies
|
# copy files and install dependencies
|
||||||
COPY . ./
|
COPY . ./
|
||||||
RUN yarn
|
RUN yarn
|
||||||
|
RUN yarn global add pm2
|
||||||
|
|
||||||
EXPOSE 4001
|
EXPOSE 4001
|
||||||
|
|
||||||
|
@ -17,4 +18,5 @@ EXPOSE 4001
|
||||||
# due to this causing yarn to stop installing dev dependencies
|
# due to this causing yarn to stop installing dev dependencies
|
||||||
# which are actually needed to get this environment up and running
|
# which are actually needed to get this environment up and running
|
||||||
ENV NODE_ENV=production
|
ENV NODE_ENV=production
|
||||||
CMD ["yarn", "run:docker"]
|
ENV CLUSTER_MODE=${CLUSTER_MODE}
|
||||||
|
CMD ["./docker_run.sh"]
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
if [[ -z $CLUSTER_MODE ]]; then
|
||||||
|
yarn run:docker
|
||||||
|
else
|
||||||
|
yarn run:docker:cluster
|
||||||
|
fi
|
|
@ -15,6 +15,7 @@
|
||||||
"build": "rimraf dist/ && tsc",
|
"build": "rimraf dist/ && tsc",
|
||||||
"postbuild": "copyfiles -u 1 src/**/*.hbs dist/",
|
"postbuild": "copyfiles -u 1 src/**/*.hbs dist/",
|
||||||
"run:docker": "node dist/index.js",
|
"run:docker": "node dist/index.js",
|
||||||
|
"run:docker:cluster": "pm2-runtime start pm2.js",
|
||||||
"build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
|
"build:docker": "docker build . -t worker-service --label version=$BUDIBASE_RELEASE_VERSION",
|
||||||
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
||||||
"dev:builder": "npm run dev:stack:init && nodemon",
|
"dev:builder": "npm run dev:stack:init && nodemon",
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
module.exports = {
|
||||||
|
apps: [
|
||||||
|
{
|
||||||
|
script: "dist/index.js",
|
||||||
|
instances: "max",
|
||||||
|
exec_mode: "cluster",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}
|
|
@ -250,11 +250,9 @@ exports.configChecklist = async function (ctx) {
|
||||||
const tenantId = getTenantId()
|
const tenantId = getTenantId()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const ONE_MINUTE = 600
|
|
||||||
|
|
||||||
ctx.body = await withCache(
|
ctx.body = await withCache(
|
||||||
`checklist:${tenantId}`,
|
`checklist:${tenantId}`,
|
||||||
ONE_MINUTE,
|
env.CHECKLIST_CACHE_TTL,
|
||||||
async () => {
|
async () => {
|
||||||
let apps = []
|
let apps = []
|
||||||
if (!env.MULTI_TENANCY || tenantId) {
|
if (!env.MULTI_TENANCY || tenantId) {
|
||||||
|
|
|
@ -20,6 +20,12 @@ if (!LOADED && isDev() && !isTest()) {
|
||||||
LOADED = true
|
LOADED = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseIntSafe(number) {
|
||||||
|
if (number) {
|
||||||
|
return parseInt(number)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
NODE_ENV: process.env.NODE_ENV,
|
NODE_ENV: process.env.NODE_ENV,
|
||||||
SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
|
SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
|
||||||
|
@ -46,6 +52,7 @@ module.exports = {
|
||||||
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
|
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
|
||||||
PLATFORM_URL: process.env.PLATFORM_URL,
|
PLATFORM_URL: process.env.PLATFORM_URL,
|
||||||
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
||||||
|
CHECKLIST_CACHE_TTL: parseIntSafe(process.env.CHECKLIST_CACHE_TTL) || 600,
|
||||||
APPS_URL: process.env.APPS_URL,
|
APPS_URL: process.env.APPS_URL,
|
||||||
_set(key, value) {
|
_set(key, value) {
|
||||||
process.env[key] = value
|
process.env[key] = value
|
||||||
|
|
Loading…
Reference in New Issue