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)
|
||||
return done(null, user)
|
||||
} catch (err) {
|
||||
console.error("User not found", err)
|
||||
console.error(`User not found`, err)
|
||||
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)
|
||||
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
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
async function login() {
|
||||
try {
|
||||
await auth.login({
|
||||
username,
|
||||
username: username.trim(),
|
||||
password,
|
||||
})
|
||||
if ($auth?.user?.forceResetPassword) {
|
||||
|
|
|
@ -16,6 +16,7 @@ ENV BUDIBASE_ENVIRONMENT=PRODUCTION
|
|||
# copy files and install dependencies
|
||||
COPY . ./
|
||||
RUN yarn
|
||||
RUN yarn global add pm2
|
||||
RUN yarn build
|
||||
|
||||
# Install client for oracle datasource
|
||||
|
@ -28,4 +29,5 @@ EXPOSE 4001
|
|||
# due to this causing yarn to stop installing dev dependencies
|
||||
# which are actually needed to get this environment up and running
|
||||
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:docs": "node ./scripts/docs/generate.js open",
|
||||
"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:down": "node scripts/dev/manage.js down",
|
||||
"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 . ./
|
||||
RUN yarn
|
||||
RUN yarn global add pm2
|
||||
|
||||
EXPOSE 4001
|
||||
|
||||
|
@ -17,4 +18,5 @@ EXPOSE 4001
|
|||
# due to this causing yarn to stop installing dev dependencies
|
||||
# which are actually needed to get this environment up and running
|
||||
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",
|
||||
"postbuild": "copyfiles -u 1 src/**/*.hbs dist/",
|
||||
"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",
|
||||
"dev:stack:init": "node ./scripts/dev/manage.js init",
|
||||
"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()
|
||||
|
||||
try {
|
||||
const ONE_MINUTE = 600
|
||||
|
||||
ctx.body = await withCache(
|
||||
`checklist:${tenantId}`,
|
||||
ONE_MINUTE,
|
||||
env.CHECKLIST_CACHE_TTL,
|
||||
async () => {
|
||||
let apps = []
|
||||
if (!env.MULTI_TENANCY || tenantId) {
|
||||
|
|
|
@ -20,6 +20,12 @@ if (!LOADED && isDev() && !isTest()) {
|
|||
LOADED = true
|
||||
}
|
||||
|
||||
function parseIntSafe(number) {
|
||||
if (number) {
|
||||
return parseInt(number)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
SELF_HOSTED: !!parseInt(process.env.SELF_HOSTED),
|
||||
|
@ -46,6 +52,7 @@ module.exports = {
|
|||
SMTP_FROM_ADDRESS: process.env.SMTP_FROM_ADDRESS,
|
||||
PLATFORM_URL: process.env.PLATFORM_URL,
|
||||
COOKIE_DOMAIN: process.env.COOKIE_DOMAIN,
|
||||
CHECKLIST_CACHE_TTL: parseIntSafe(process.env.CHECKLIST_CACHE_TTL) || 600,
|
||||
APPS_URL: process.env.APPS_URL,
|
||||
_set(key, value) {
|
||||
process.env[key] = value
|
||||
|
|
Loading…
Reference in New Issue