Installing and deploying Kotahi

Questions about installing and deploying Kotahi

Dear Team,

used Ubuntu 20.04 for deployment.
I have followed the deployment guide given below link:


step 1:
apt-get install postgresql git nodejs npm (success)
step 2:
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
installed yarn.
step 3:
postgres=# create database kotahi;
CREATE DATABASE
postgres=# create user kotahi with password ‘hijusttesting’;
CREATE ROLE
postgres=# grant all privileges on database kotahi to kotahi;
GRANT
Created Database and user with role.
step 4:
cloned from git lab and installed all the dependencies using yarn.
step 5:
registered with public API and got client id and client secret.
export ORCID_CLIENT_ID=YOUR_ORCID_CLIENT_ID
export ORCID_CLIENT_SECRET=YOUR_ORCID_CLIENT_SECRET
successfully completed the step.
step 6:
configure the base url for redirects
It’s in config, ‘pubsweet-server’, and ‘baseUrl’
I have checked in config/development.js for pubsweet-server and base Uri.
‘pubsweet-server’: {

db: {

  database: 'simplej', // want to create or default it will be created.

  user: 'test', // want to create or default it will be created.

},

port: process.env.PORT || 3000,

pool: { min: 0, max: 10, idleTimeoutMillis: 1000 },

baseUrl: `http://localhost:4000`,

secret: 'secret-string',

},

‘pubsweet-client’: {

baseUrl: `http://localhost:4000`,

},

mailer: {

from: 'simplej@example.com',

path: `${__dirname}/test-mailer`,

},

dbManager: {

username: 'admin',

password: '12345678',

email: 'admin@admin.com',

admin: true,

},

struck in this step.

Step 7:
Creating the admin user:
Users are automatically created when logging in with ORCID. You can make users admin by going into the console (using yarn console ) and updating their admin flag, e.g. await User.query().update({admin: true})
can not able to create user with yarn console, below is the error.

DBError: update “users” set “type” = $1, “admin” = $2, “updated” = $3 - relation “users” does not exist
at wrapError (/root/kotahi/kotahi/node_modules/db-errors/lib/dbErrors.js:19:14)
(mailto:/root/kotahi/kotahi/node_modules/@pubsweet/base-model/node_modules/objection/lib/queryBuilder/QueryBuilder.js:687:20))
at processTicksAndRejections (internal/process/task_queues.js:97:5) {
nativeError: error: update “users” set “type” = $1, “admin” = $2, “updated” = $3 - relation “users” does not exist
at Function.value (/root/kotahi/kotahi/node_modules/knex/lib/util/make-knex.js:90:29)
(mailto:/root/kotahi/kotahi/node_modules/@pubsweet/base-model/node_modules/objection/lib/queryBuilder/QueryBuilder.js:684:28))
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async repl:1:24 {
length: 103,
severity: ‘ERROR’,
code: ‘42P01’,
detail: undefined,
hint: undefined,
position: ‘8’,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: ‘parse_relation.c’,
line: ‘1180’,
routine: ‘parserOpenTable’,
originalStack: ‘error: update “users” set “type” = $1, “admin” = $2, “updated” = $3 - relation “users” does not exist\n’ +
’ at Connection.parseE (/root/kotahi/kotahi/node_modules/pg/lib/connection.js:614:13)\n’ +
’ at Connection.parseMessage (/root/kotahi/kotahi/node_modules/pg/lib/connection.js:413:19)\n’ +
’ at Socket. (/root/kotahi/kotahi/node_modules/pg/lib/connection.js:129:22)\n’ +
’ at Socket.emit (events.js:315:20)\n’ +
’ at Socket.EventEmitter.emit (domain.js:483:12)\n’ +
’ at addChunk (_stream_readable.js:295:12)\n’ +
’ at readableAddChunk (_stream_readable.js:271:9)\n’ +
’ at Socket.Readable.push (_stream_readable.js:212:10)\n’ +
’ at TCP.onStreamRead (internal/stream_base_commons.js:186:23)\n’ +
’ at TCP.callbackTrampoline (internal/async_hooks.js:120:14)’
},
client: ‘postgres’
}

Step 8:
docker run -e DATABASE_URL="postgres://kotahi:hijusttesting@localhost/kotahi" -e WAIT_SERVICE_PORT="localhost:5432" pubsweet/job-xsweet

below error was occured.

  • npx wait-for-it localhost:5432 --strict --timeout=300 – node ./src/xsweet.js
    wait-for-it: waiting 300 seconds for localhost:5432
    wait-for-it: timeout occurred after waiting 300 seconds for localhost:5432
    wait-for-it: strict mode, refusing to execute subprocess

Please guide me on this.

Hmm, it seems like there’s a missing step there.

After you’ve created the database, but before you do anything with it, you should run yarn pubsweet migrate.

The problem is you have a db, there’s no tables in it yet, and you’re telling the server to add a row to the users table, which doesn’t exist. The migrate command will fix that for you by creating all the tables.

Let me know if it works.

I’ll also update the instructions to include the missing step.

Thanks Yannis, will try that and let you know.

Hi Yannis,

I tried to run the command
yarn pubsweet migrate (runned succesfully)

but could not able to start the pubsweet server using yarn pubsweet start:server

errors are below:
$ /opt/kotahi/node_modules/.bin/pubsweet start:server
info: Starting PubSweet app’s server (development)
$ /opt/kotahi/node_modules/.bin/node-dev /opt/kotahi/node_modules/pubsweet-server/src/start.js
Type “Object” is missing a “__resolveType” resolver. Pass false into “resolverValidationOptions.requireResolversForResolveType” to disable this warning.
info: Registered component ./server/model-team/src
info: Registered component ./server/model-user/src
info: Registered component ./server/model-manuscript/src/
info: Registered component ./server/model-file/src/
info: Registered component ./server/component-xpub-review-backend/src/
info: Registered server component ./server/component-xpub-review-backend/src/
info: Registered component ./server/model-review/src/
info: Registered component ./server/formbuilder/src/
info: Registered component @pubsweet/job-xsweet
info: Registered server component @pubsweet/job-xsweet
info: Registered component ./server/model-channel/src
info: Registered component ./server/model-message/src
info: Registered component ./server/profile-upload
info: Registered server component ./server/profile-upload
info: Registered component ./server/auth-orcid
(node:2486) UnhandledPromiseRejectionWarning: Error: Configuration property “auth-orcid” is not defined
at Config.get (/opt/kotahi/node_modules/config/lib/config.js:182:11)
at module.exports (/opt/kotahi/server/auth-orcid/orcid.js:19:19)
at registerRecursively (/opt/kotahi/node_modules/pubsweet-server/src/register-components.js:11:22)
at /opt/kotahi/node_modules/pubsweet-server/src/register-components.js:22:7
at Array.forEach ()
at module.exports (/opt/kotahi/node_modules/pubsweet-server/src/register-components.js:21:39)
at configureApp (/opt/kotahi/server/app.js:81:3)
at startServer (/opt/kotahi/node_modules/pubsweet-server/src/start-server.js:30:25)
at Object. (/opt/kotahi/node_modules/pubsweet-server/src/start.js:7:1)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Module._extensions…js (internal/modules/cjs/loader.js:1035:10)
at Object.nodeDevHook [as .js] (/opt/kotahi/node_modules/node-dev/lib/hook.js:61:7)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Module.require (internal/modules/cjs/loader.js:903:19)
at require (internal/modules/cjs/helpers.js:74:18)
(node:2486) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2486) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 7.05s.

also i could not able to start docker job run for
docker run -e DATABASE_URL="postgres://kotahi:password@host.docker.internal/kotahi" -e WAIT_SERVICE_PORT="host.docker.internal:5432" pubsweet/job-xsweet

below error occured:

  • npx wait-for-it localhost:5432 --strict --timeout=300 – node ./src/xsweet.js
    wait-for-it: waiting 300 seconds for localhost:5432
    wait-for-it: timeout occurred after waiting 300 seconds for localhost:5432
    wait-for-it: strict mode, refusing to execute subprocess

Please help me on this.

Hi Yannis,

I updated the environtmental variable as below:
export ORCID_CLIENT_ID=Id (got from sandbox.org)
export ORCID_CLIENT_SECRET=secret (got from sand box.org)

after I have tried to up pubsweet server by using
yarn pubsweet start:server
below error was occured:

info: App is listening on port 3000
(node:3747) UnhandledPromiseRejectionWarning: error:
at Object.raw (/opt/kotahi/node_modules/knex/lib/util/make-knex.js:114:30)
at Function.value (/opt/kotahi/node_modules/knex/lib/util/make-knex.js:90:29)
at Object.executeSql (/opt/kotahi/node_modules/pubsweet-server/src/jobs/index.js:19:17)
at Contractor.create (/opt/kotahi/node_modules/pg-boss/src/contractor.js:57:19)
at Contractor.start (/opt/kotahi/node_modules/pg-boss/src/contractor.js:76:18)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async PgBoss.start (/opt/kotahi/node_modules/pg-boss/src/index.js:82:5)
at async startJobQueue (/opt/kotahi/node_modules/pubsweet-server/src/jobs/index.js:60:5)

sorry could not able to paste whole error, since it restricted more than two links.

please help me.

Sorry @mohan, but I cannot seem to be able to replicate this error.

A possible culprit could be your db’s credentials vs the docker command in your previous post.
The command in the instructions seems to have credentials and port number hardcoded in it.

Can you stop the job-xsweet container and re-run it using your credentials?

You can use this as a reference:
DATABASE_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:${POSTGRES_PORT}/${POSTGRES_DB}"

Hi Yannis,

Thanks for your reply,

I have stopped job-xsweet container and checked my credential and changed accordingly and run the command as below:

docker run -e DATABASE_URL=“postgres://kotahi:hijusttesting@localhost/kotahi” -e WAIT_SERVICE_PORT=“localhost:5432” pubsweet/job-xsweet

but still it not running the container shows below error:

  • npx wait-for-it localhost:5432 --strict --timeout=300 – node ./src/xsweet.js
    wait-for-it: waiting 300 seconds for localhost:5432
    wait-for-it: timeout occurred after waiting 300 seconds for localhost:5432
    wait-for-it: strict mode, refusing to execute subprocess

Note:
I am trying to depoly in UBUNTU server
I deployed pub sweet application from the giblab using below link and hosted successfully without any hussle.
https://pubsweet.coko.foundation/#/Getting%20started

Also the postgres service is up and running successfully at host 0.0.0.0, 5432 port

Please help me on this, I trying this deployment for a week but still no luck.
If possible could you please update deployment guide.
Also I found “simplej” references in the source code.

Regards,
Mohan Kumar. A

Hi Yannis,

Please let me know, if there is any update.

Regards,
Mohan Kumar. A

FYI @mohan I haven’t forgotten you.
I think I’ve found a solution, but it will take some time to implement and update the repo.

Will keep you posted.

Thanks Yannis.

@mohan can you try this?

docker run -e DATABASE_URL="postgres://kotahi:justtesting@localhost:5432/kotahi" -e WAIT_TIMEOUT=3 -e WAIT_SERVICE_PORT=localhost:5432 --name xsweet --network="host" pubsweet/job-xsweet

The key change is --network="host". The problem was that ‘localhost’ for the docker container wasn’t the OS’s localhost, but the container’s internal localhost.

I also changed WAIT_TIMEOUT to 3 (from 300!), as the reason I couldn’t reproduce the exact error initially was that I didn’t wait for 5 minutes… Feel free to change the timeout to whatever you find reasonable.

What it does is wait for the url in WAIT_SERVICE_PORT for WAIT_TIMEOUT seconds to become available.

Let me know if it works for you, so that I update the docs accordingly.

Hi Yannis,

Thanks for the reply,

I have tried with that command, now new error has thrown.
Please find the attached images.

I have checked running docker containers and it shows xsweet container is up.

Please guide me.

Regards,
Mohan Kumar. A

Since I cant able to upload multiple images,
Then I have run command ‘yarn start:server-and-client’
below error has throwned.

This is most probably because the application server wasn’t running.
It’s a bit counterintuitive, I know, but the server needs to be up for job-xsweet to be brought up succesfully.

Edit: referring to the pgboss error here

On the auth-orcid error, do you have these environment variables set and sourced?

Quick way to check is to echo $ORCID_CLIENT_ID from the shell where your server command is going to run and see if it prints out the correct value.

Hi Yannis,

Thanks for the reply,
I have checked the environtment variable and it was null, I have set the ORCID_CLIENT_ID and ORCID_CLIENT_PASSWORD, then I tried to run the pubsweet server and now it throws bad auth error in server/subscriptions.js, please find below image for your reference.

Regards,
Mohan Kumar. A

That just means that the authentication token is not valid any more. Simply reloading the webpage client-side should fix that. Or maybe try logging out and in again.

9 posts were merged into an existing topic: Unable to upload word file into the system

Hi yannis,
Thanks for the reply,
Now auth-orcid server registered, but below error had throwned