Strapi on Plesk Windows, port redirect error - strapi

I want to set up Strapi (v4) on a Plesk (Windows) / nodeJS (16.16) / MySQL (MariaDb 10.6.9) environment but I get the error: options.port should be >= 0 and < 65536. Received NaN.
Strapi Version: 4
Operating System: Windows 2022 Datacenter + Plesk Obsidian
Database: MariaDB 10.6.9
Node Version: 16.16
NPM Version: 8.19.2
Yarn Version: N/A
I did the installation like this :
$ npx create-strapi-app plesk-strapi --no-run
$ # custom Install
$ # wait for installation process to finish
$ cd strapi-demo.xyz.com
$ npm run build
I configure the boot of the application at the root of the project ‘/app.js’
const strapi = require('#strapi/strapi'); //require('strapi');
strapi().start();
And file ‘config/server.js’ :
module.exports = ({ env }) => ({
host: env('HOST', process.env.HOST || '127.0.0.1'),
port: env.int('PORT', parseInt(process.env.PORT) || 80),
app: {
keys: env.array('APP_KEYS'),
},
});
And file ‘/.env’ :
HOST=127.0.0.1
PORT=80
APP_KEYS= mySecretKey1, mySecretKey2, mySecretKey3, mySecretKey4
API_TOKEN_SALT= mySecretSaltKey
ADMIN_JWT_SECRET=mySecretKey
JWT_SECRET=mySecretKey
# `sqlite` or `mysql`
DATABASE_CONNECTION_NAME=mysql
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_NAME=myDbName
DATABASE_USERNAME=MyDbUsername
DATABASE_PASSWORD=MyDbPassword
Plesk nodeJS config :
return Error :
[2022-10-20 09:33:55.897] [34mdebug[39m: ⛔️ Server wasn't able to start properly.
[2022-10-20 09:33:55.904] [31merror[39m: options.port should be >= 0 and < 65536. Received NaN.
RangeError [ERR_SOCKET_BAD_PORT]: options.port should be >= 0 and < 65536. Received NaN.
at new NodeError (node:internal/errors:372:5)
at validatePort (node:internal/validators:217:11)
at Server.listen (node:net:1500:5)
at Object.listen (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\#strapi\strapi\lib\services\server\index.js:122:25)
at E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\#strapi\strapi\lib\Strapi.js:302:21
at new Promise (<anonymous>)
at Strapi.listen (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\#strapi\strapi\lib\Strapi.js:281:12)
at Strapi.start (E:\plesk\vhost\xyz.com\strapi-demo.xyz.com\node_modules\#strapi\strapi\lib\Strapi.js:215:18)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

Related

Possible reasons for groovy program running as kubernetes job dumping threads during execution

I have a simple groovy script that leverages the GPars library's withPool functionality to launch HTTP GET requests to two internal API endpoints in parallel.
The script runs fine locally, both directly as well as a docker container.
When I deploy it as a Kubernetes Job (in our internal EKS cluster: 1.20), it runs there as well, but the moment it hits the first withPool call, I see a giant thread dump, but the execution continues, and completes successfully.
NOTE: Containers in our cluster run with the following pod security context:
securityContext:
fsGroup: 2000
runAsNonRoot: true
runAsUser: 1000
Environment
# From the k8s job container
groovy#app-271df1d7-15848624-mzhhj:/app$ groovy --version
WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector
Groovy Version: 4.0.0 JVM: 17.0.2 Vendor: Eclipse Adoptium OS: Linux
groovy#app-271df1d7-15848624-mzhhj:/app$ ps -ef
UID PID PPID C STIME TTY TIME CMD
groovy 1 0 0 21:04 ? 00:00:00 /bin/bash bin/run-script.sh
groovy 12 1 42 21:04 ? 00:00:17 /opt/java/openjdk/bin/java -Xms3g -Xmx3g --add-modules=ALL-SYSTEM -classpath /opt/groovy/lib/groovy-4.0.0.jar -Dscript.name=/usr/bin/groovy -Dprogram.name=groovy -Dgroovy.starter.conf=/opt/groovy/conf/groovy-starter.conf -Dgroovy.home=/opt/groovy -Dtools.jar=/opt/java/openjdk/lib/tools.jar org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /opt/groovy/conf/groovy-starter.conf --classpath . /tmp/script.groovy
groovy 116 0 0 21:05 pts/0 00:00:00 bash
groovy 160 116 0 21:05 pts/0 00:00:00 ps -ef
Script (relevant parts)
#Grab('org.codehaus.gpars:gpars:1.2.1')
import static groovyx.gpars.GParsPool.withPool
import groovy.json.JsonSlurper
final def jsl = new JsonSlurper()
//...
while (!(nextBatch = getBatch(batchSize)).isEmpty()) {
def devThread = Thread.start {
withPool(poolSize) {
nextBatch.eachParallel { kw ->
String url = dev + "&" + "query=$kw"
try {
def response = jsl.parseText(url.toURL().getText(connectTimeout: 10.seconds, readTimeout: 10.seconds,
useCaches: true, allowUserInteraction: false))
devResponses[kw] = response
} catch (e) {
println("\tFailed to fetch: $url | error: $e")
}
}
}
}
def stgThread = Thread.start {
withPool(poolSize) {
nextBatch.eachParallel { kw ->
String url = stg + "&" + "query=$kw"
try {
def response = jsl.parseText(url.toURL().getText(connectTimeout: 10.seconds, readTimeout: 10.seconds,
useCaches: true, allowUserInteraction: false))
stgResponses[kw] = response
} catch (e) {
println("\tFailed to fetch: $url | error: $e")
}
}
}
}
devThread.join()
stgThread.join()
}
Dockerfile
FROM groovy:4.0.0-jdk17 as builder
USER root
RUN apt-get update && apt-get install -yq bash curl wget jq
WORKDIR /app
COPY bin /app/bin
RUN chmod +x /app/bin/*
USER groovy
ENTRYPOINT ["/bin/bash"]
CMD ["bin/run-script.sh"]
The bin/run-script.sh simply downloads the above groovy script at runtime and executes it.
wget "$GROOVY_SCRIPT" -O "$LOCAL_FILE"
...
groovy "$LOCAL_FILE"
As soon as the execution hits the first call to withPool(poolSize), there's a giant thread dump, but execution continues.
I'm trying to figure out what could be causing this behavior. Any ideas 🤷🏽‍♂️?
Thread dump
For posterity, answering my own question here.
The issue turned out to be this log4j2 JVM hot-patch that we're currently leveraging to fix the recent log4j2 vulnerability. This agent (running as a DaemonSet) patches all running JVMs in all our k8s clusters.
This, somehow, causes my OpenJDK 17 based app to thread dump. I found the same issue with an ElasticSearch 8.1.0 deployment as well (also uses a pre-packaged OpenJDK 17). This one is a service, so I could see a thread dump happening pretty much every half hour! Interestingly, there are other JVM services (and some SOLR 8 deployments) that don't have this issue 🤷🏽‍♂️.
Anyway, I worked with our devops team to temporarily exclude the node that deployment was running on, and lo and behold, the thread dumps disappeared!
Balance in the universe has been restored 🧘🏻‍♂️.

sap-cf-mailer VError: No service matches destination

I have a SAP CAP Nodejs application and I'm trying to send emails from the CAP application using sap-cf-mailer package.
I've created a destination service in the BTP as mentioned in the sample and when I'm trying to deploy the application to BTP it failed.
When I run the application locally using cds watch, it gives following error
VError: No service matches destination
This is my mta.yaml
## Generated mta.yaml based on template version 0.4.0
## appName = CapTest
## language=nodejs; multitenant=false
## approuter=
_schema-version: '3.1'
ID: CapTest
version: 1.0.0
description: "A simple CAP project."
parameters:
enable-parallel-deployments: true
build-parameters:
before-all:
- builder: custom
commands:
- npm install --production
- npx -p #sap/cds-dk cds build --production
modules:
# --------------------- SERVER MODULE ------------------------
- name: CapTest-srv
# ------------------------------------------------------------
type: nodejs
path: gen/srv
parameters:
buildpack: nodejs_buildpack
requires:
# Resources extracted from CAP configuration
- name: CapTest-db
- name: captest-destination-srv
provides:
- name: srv-api # required by consumers of CAP services (e.g. approuter)
properties:
srv-url: ${default-url}
# -------------------- SIDECAR MODULE ------------------------
- name: CapTest-db-deployer
# ------------------------------------------------------------
type: hdb
path: gen/db
parameters:
buildpack: nodejs_buildpack
requires:
# 'hana' and 'xsuaa' resources extracted from CAP configuration
- name: CapTest-db
resources:
# services extracted from CAP configuration
# 'service-plan' can be configured via 'cds.requires.<name>.vcap.plan'
# ------------------------------------------------------------
- name: CapTest-db
# ------------------------------------------------------------
type: com.sap.xs.hdi-container
parameters:
service: hana # or 'hanatrial' on trial landscapes
service-plan: hdi-shared
properties:
hdi-service-name: ${service-name}
- name: captest-destination-srv
type: org.cloudfoundry.existing-service
This is the js file of the CDS service
const cds = require('#sap/cds')
const SapCfMailer = require('sap-cf-mailer').default;
const transporter = new SapCfMailer("MAILTRAP");
module.exports = cds.service.impl(function () {
this.on('sendmail', sendmail);
});
async function sendmail(req) {
try {
const result = await transporter.sendMail({
to: 'someoneimportant#sap.com',
subject: `This is the mail subject`,
text: `body of the email`
});
return JSON.stringify(result);
}
catch{
}
};
I'm following below samples for this
Send an email from a nodejs app
Integrate email to CAP application
Did you create your default-.. json files? They are required to connect to remote services on your BTP tenant. You can find more info about this on SAP blogs like this one:
https://blogs.sap.com/2020/04/03/sap-application-router/
You could also use the sap-cf-localenv command:
https://github.com/jowavp/sap-cf-localenv
This tool is experimental,a s far as I know, this only works for the CF CLI V6. Higher version are fetching the service keys in another format, which leads to the command to fail.
Kind regards,
Thomas

Failed: script timeout: result was not received in 20 seconds

I have an e2e protractor-jasmine test in my angular application. I've just run the exact same test several times in a row and it stops at exactly one step. giving the same error:
'Failed: script timeout: result was not received in 20 seconds'
What I have tried:
1. I attempted to make this an async function: ... header', async () => { ...
2. I have tried await(ing) the element: await element(by.css("[ng-click='siteDocLibCtrl.managePermissionsDialog($event)']")).click();
3. I have tried to browser.sleep(3000)
Jasmine version:2.8.0
npm version:
npm: '6.4.1',
ares: '1.15.0',
cldr: '33.1',
http_parser: '2.8.0',
icu: '62.1',
modules: '64',
napi: '3',
nghttp2: '1.34.0',
node: '10.15.0',
openssl: '1.1.0j',
tz: '2018e',
unicode: '11.0',
uv: '1.23.2',
v8: '6.8.275.32-node.45',
zlib: '1.2.11'
element.all(by.repeater("file in siteDocLibCtrl.files | filter:global.search | orderBy:orderByField:reverseSort")).get(0).click(); //selects 1st element
element(by.css("[ng-click='siteDocLibCtrl.managePermissionsDialog($event)']")).click();
The output error i am getting is below:
Failed: script timeout: result was not received in 20 seconds
(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64)[0m
Stack:
ScriptTimeoutError: script timeout: result was not received in 20 seconds
(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=2.46.628402 (536cd7adbad73a3783fdc2cab92ab2ba7ec361e1),platform=Windows NT 10.0.17134 x86_64)
at Object.checkLegacyResponse (C:\Users\Jagdeep\eclipse-workspace\ProtractorTutorial\node_modules\selenium-webdriver\lib\error.js:546:15)
at parseHttpResponse (C:\Users\Jagdeep\eclipse-workspace\ProtractorTutorial\node_modules\selenium-webdriver\lib\http.js:509:13)
at doSend.then.response (C:\Users\Jagdeep\eclipse-workspace\ProtractorTutorial\node_modules\selenium-webdriver\lib\http.js:441:30)
at process._tickCallback (internal/process/next_tick.js:68:7)
Try add this line before the test:
browser.ignoreSynchronization = true;

CouchDB 3-node cluster (Windows) - multiple erlang errors

Im receiving multiple erlang errors in my CouchDB 2.1.1 cluster (3 nodes/Windows), see errors and node configuration below:
3 nodes (10.0.7.4 - 10.0.7.6), Azure application gateway is used as load balancer.
Why do these errors appear? system resources of the nodes are far from overload.
I would be thankful for any help - thanks in advance.
Errors:
rexi_server: from: couchdb#10.0.7.4(<0.14976.568>) mfa: fabric_rpc:changes/3 exit:timeout [{rexi,init_stream,1,[{file,"src/rexi.erl"},{line,256}]},{rexi,stream_last,2,[{file,"src/rexi.erl"},{line,224}]},{fabric_rpc,changes,4,[{file,"src/fabric_rpc.erl"},{line,86}]},{rexi_server,init_p,3,[{file,"src/rexi_server.erl"},{line,139}]}]
rexi_server: from: couchdb#10.0.7.6(<13540.24597.655>) mfa: fabric_rpc:all_docs/3 exit:timeout [{rexi,init_stream,1,[{file,"src/rexi.erl"},{line,256}]},{rexi,stream2,3,[{file,"src/rexi.erl"},{line,204}]},{fabric_rpc,view_cb,2,[{file,"src/fabric_rpc.erl"},{line,308}]},{couch_mrview,finish_fold,2,[{file,"src/couch_mrview.erl"},{line,642}]},{rexi_server,init_p,3,[{file,"src/rexi_server.erl"},{line,139}]}]
rexi_server: from: couchdb#10.0.7.6(<13540.5991.623>) mfa: fabric_rpc:all_docs/3 exit:timeout [{rexi,init_stream,1,[{file,"src/rexi.erl"},{line,256}]},{rexi,stream2,3,[{file,"src/rexi.erl"},{line,204}]},{fabric_rpc,view_cb,2,[{file,"src/fabric_rpc.erl"},{line,308}]},{couch_mrview,map_fold,3,[{file,"src/couch_mrview.erl"},{line,511}]},{couch_btree,stream_kv_node2,8,[{file,"src/couch_btree.erl"},{line,848}]},{couch_btree,fold,4,[{file,"src/couch_btree.erl"},{line,222}]},{couch_db,enum_docs,5,[{file,"src/couch_db.erl"},{line,1450}]},{couch_mrview,all_docs_fold,4,[{file,"src/couch_mrview.erl"},{line,425}]}]
req_err(3206982071) unknown_error : normal [<<"mochiweb_request:recv/3 L180">>,<<"mochiweb_request:stream_unchunked_body/4 L540">>,<<"mochiweb_request:recv_body/2 L214">>,<<"chttpd:body/1 L636">>,<<"chttpd:json_body/1 L649">>,<<"chttpd:json_body_obj/1 L657">>,<<"chttpd_db:db_req/2 L386">>,<<"chttpd:process_request/1 L295">>]
System running to use fully qualified hostnames ** ** Hostname localhost is illegal
COMPACTION-ERRORS
Supervisor couch_secondary_services had child compaction_daemon started with couch_compaction_daemon:start_link() at <0.18509.478> exit with reason {compaction_loop_died,{timeout,{gen_server,call,[couch_server,get_server]}}} in context child_terminated
CRASH REPORT Process couch_compaction_daemon (<0.18509.478>) with 0 neighbors exited with reason: {compaction_loop_died,{timeout,{gen_server,call,[couch_server,get_server]}}} at gen_server:terminate/7(line:826) <= proc_lib:init_p_do_apply/3(line:240); initial_call: {couch_compaction_daemon,init,['Argument__1']}, ancestors: [couch_secondary_services,couch_sup,<0.200.0>], messages: [], links: [<0.12665.492>], dictionary: [], trap_exit: true, status: running, heap_size: 987, stack_size: 27, reductions: 3173
gen_server couch_compaction_daemon terminated with reason: {compaction_loop_died,{timeout,{gen_server,call,[couch_server,get_server]}}} last msg: {'EXIT',<0.23195.476>,{timeout,{gen_server,call,[couch_server,get_server]}}} state: {state,<0.23195.476>,[]}
Error in process <0.16890.22> on node 'couchdb#10.0.7.4' with exit value: {{rexi_DOWN,{'couchdb#10.0.7.5',noproc}},[{mem3_rpc,rexi_call,2,[{file,"src/mem3_rpc.erl"},{line,269}]},{mem3_rep,calculate_start_seq,1,[{file,"src/mem3_rep.erl"},{line,194}]},{mem3_rep,repl,2,[{file,"src/mem3_rep.erl"},{line,175}]},{mem3_rep,go,1,[{file,"src/mem3_rep.erl"},{line,81}]},{mem3_sync,'-start_push_replication/1-fun-0-',2,[{file,"src/mem3_sync.erl"},{line,208}]}]}
#vm.args
-name couchdb#10.0.7.4
-setcookie monster
-kernel error_logger silent
-sasl sasl_error_logger false
+K true
+A 16
+Bd -noinput
+Q 134217727`
local.ini
[fabric]
request_timeout = infinity
[couchdb]
max_dbs_open = 10000
os_process_timeout = 20000
uuid =
[chttpd]
port = 5984
bind_address = 0.0.0.0
[httpd]
socket_options = [{recbuf, 262144}, {sndbuf, 262144}, {nodelay, true}]
enable_cors = true
[couch_httpd_auth]
secret =
[daemons]
compaction_daemon={couch_compaction_daemon, start_link, []}
[compactions]
_default = [{db_fragmentation, "50%"}, {view_fragmentation, "50%"}, {from, "23:00"}, {to, "04:00"}]
[compaction_daemon]
check_interval = 300
min_file_size = 100000
[vendor]
name = COUCHCLUSTERNODE0X
[admins]
adminuser =
[cors]
methods = GET, PUT, POST, HEAD, DELETE
headers = accept, authorization, content-type, origin, referer
origins = *
credentials = true
[query_server_config]
os_process_limit = 2000
os_process_soft_limit = 1000

Karma & Jasmine weird behavior when using the word 'base'

I am here to ask for some help because I can't reach a solution and I have spent so much time on this.
The problem is a weird behavior in karma + jasmine tests, initially I thought that the problem was in AngularJs code but, stripping down by stripping down I reached the point where there is nothing else to remove and the problem is 100% not in angular.
The actual code that I am using is this:
test.js:
'use strict';
describe('Unit tests suite', function () {
it('test', function () {
expect('base').toEqual('');
});
});
karma.conf.js:
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: ['*.js'],
exclude: [],
preprocessors: {},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
})
}
Absolutely nothing else. The result of that test is:
13 02 2016 04:32:39.559:WARN [karma]: No captured browser, open http://localhost:9876/
13 02 2016 04:32:39.571:INFO [karma]: Karma v0.13.15 server started at http://localhost:9876/
13 02 2016 04:32:39.578:INFO [launcher]: Starting browser PhantomJS
13 02 2016 04:32:41.248:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket HiC4WW_4235Nlf0rAAAA with id 54292207
PhantomJS 2.1.1 (Mac OS X 0.0.0) Unit tests suite test FAILED
Expected '/Users/Gianmarco/Desktop/test' to equal ''.
/Users/Gianmarco/Desktop/test/test.js:5:31
PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 1 of 1 (1 FAILED) ERROR (0.003 secs / 0.003 secs)
As you can see it seems that the word "base" is being changed with the path of the folder. This is making me going nuts I can't figure out why it is doing so.
I tried both with MacOSX and Ubuntu 14.04 and the result is the same.
To prepare the folder I did this:
mkdir test
cd test
npm install jasmine-core karma-cli karma-jasmine karma-phantomjs-launcher phantomjs-prebuilt --save
karma init
karma start
and of course my system had a npm install karma-cli -g some time ago.
The versions are:
jasmine-core#2.4.1
karma#0.13.21
karma-cli#0.1.2
karma-jasmine#0.3.7
karma-phantomjs-launcher#1.0.0
phantomjs-prebuilt#2.1.4
The same behaviour is obtained using the word absolute, that is replaced with an empty string
I believe its a problem with the default reporter in karma (progress) it appears the URL_REGEX matches both base and absolute as all the rest of the regex is optional.
var URL_REGEXP = new RegExp('(?:https?:\\/\\/[^\\/]*)?\\/?' +
'(base|absolute)' + // prefix
'((?:[A-z]\\:)?[^\\?\\s\\:]*)' + // path
'(\\?\\w*)?' + // sha
'(\\:(\\d+))?' + // line
'(\\:(\\d+))?' + // column
'', 'g')
https://github.com/karma-runner/karma/blob/684ab1838c6ad7127df2f1785c1f56520298cd6b/lib/reporter.js#L25

Resources