502 Bad Gateway nginx VM - nginx

I get a 502 Bad Gateway on my VM webserver and I don't know what to do. The error message I get is the following when running pm2 log.
/root/.pm2/logs/server-error-0.log last 15 lines:
0|server | at Object.Module._extensions..js
(internal/modules/cjs/loader.js:713:10)
0|server | at Module.load (internal/modules/cjs/loader.js:612:32)
0|server | at tryModuleLoad
(internal/modules/cjs/loader.js:551:12)
0|server | at Function.Module._load
(internal/modules/cjs/loader.js:543:3)
0|server | Error: listen EADDRINUSE :::9000
0|server | at Server.setupListenHandle [as _listen2]
(net.js:1330:14)
0|server | at listenInCluster (net.js:1378:12)
0|server | at Server.listen (net.js:1466:7)
0|server | at Function.listen
(/var/www/wsApp/client/node_modules/express/lib/application.js:618:24)
0|server | at Object.<anonymous>
(/var/www/wsApp/client/server.js:22:5)
0|server | at Module._compile
(internal/modules/cjs/loader.js:702:30)
0|server | at Object.Module._extensions..js
(internal/modules/cjs/loader.js:713:10)
0|server | at Module.load (internal/modules/cjs/loader.js:612:32)
0|server | at tryModuleLoad
(internal/modules/cjs/loader.js:551:12)
0|server | at Function.Module._load
(internal/modules/cjs/loader.js:543:3)
I also get this error message
'upstream prematurely closed connection while reading response header from upstream'

Related

How to fix this after firebase update?

Heading
PS D:\Progetti\SitoWebLavoro> firebase deploy
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'semver'
Require stack:
C:\Users\Fabio\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (C:\Users\Fabio\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js:4:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\Users\Fabio\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js'
]
}

Using Meteor Cluster for microservice

Based on the simple implementation of Meteor Cluster MicroServices the doc I have this implementation for 2 services to communicate.
AppUI
export default CLUSTER_DISCOVERY_URL="mongodb://localhost:3000/meteor";
Cluster.connect(CLUSTER_DISCOVERY_URL);
Cluster.register('appui_service');
loggerService = Cluster.discoverConnection('logger_service');
LoggerService
export default CLUSTER_DISCOVERY_URL="mongodb://localhost:3300/meteor";
Cluster.connect(CLUSTER_DISCOVERY_URL);
Cluster.register('logger_service');
loggerService = Cluster.discoverConnection('appui_service');
As it is, AppiUI runs on port 3000, while LoggerService is on port 3300. When I tried, started the servers, I kept on getting this error log.
I20180719-10:17:27.259(1)? Cluster: connecting to 'mongodb' discovery backend
I20180719-10:17:27.260(1)? Cluster: with options: undefined
W20180719-10:17:27.274(1)? (STDERR) /Users/kehindeadeoya/.meteor/packages/meteor-tool/.1.7.0_3.w8zcf.uowlh++os.osx.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:313
W20180719-10:17:27.274(1)? (STDERR) throw(ex);
W20180719-10:17:27.274(1)? (STDERR) ^
W20180719-10:17:27.275(1)? (STDERR)
W20180719-10:17:27.275(1)? (STDERR) Error: failed to connect to [localhost:27017]
W20180719-10:17:27.275(1)? (STDERR) at exports.ConnectionPool.<anonymous> (/Users/kehindeadeoya/.meteor/packages/meteorhacks_cluster/.1.6.9.y65r.xg1qe3++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/server.js:555:25)
W20180719-10:17:27.275(1)? (STDERR) at emitThree (events.js:136:13)
W20180719-10:17:27.275(1)? (STDERR) at exports.ConnectionPool.emit (events.js:217:7)
W20180719-10:17:27.275(1)? (STDERR) at exports.Connection.<anonymous> (/Users/kehindeadeoya/.meteor/packages/meteorhacks_cluster/.1.6.9.y65r.xg1qe3++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:156:15)
W20180719-10:17:27.276(1)? (STDERR) at emitTwo (events.js:126:13)
W20180719-10:17:27.276(1)? (STDERR) at exports.Connection.emit (events.js:214:7)
W20180719-10:17:27.276(1)? (STDERR) at Socket.<anonymous> (/Users/kehindeadeoya/.meteor/packages/meteorhacks_cluster/.1.6.9.y65r.xg1qe3++os+web.browser+web.cordova/npm/node_modules/mongodb/lib/mongodb/connection/connection.js:534:10)
W20180719-10:17:27.276(1)? (STDERR) at emitOne (events.js:116:13)
W20180719-10:17:27.276(1)? (STDERR) at Socket.emit (events.js:211:7)
W20180719-10:17:27.277(1)? (STDERR) at emitErrorNT (internal/streams/destroy.js:64:8)
W20180719-10:17:27.277(1)? (STDERR) at _combinedTickCallback (internal/process/next_tick.js:138:11)
W20180719-10:17:27.277(1)? (STDERR) at process._tickDomainCallback (internal/process/next_tick.js:218:9)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.
I don't understand what the discovery backend means. Secondly, I want to use Meteor's default bundled Mongo for this test, not a stand-alone Mongo, what can I do to get pass this error?

Importing css into Meteor project results in SyntaxError: Unexpected token

**EDIT: I solved this issue.
For imports to work with Meteor, you have to put your code in an /imports/ directory. Here's the official guide on structuring your app. It's odd because I was importing and exporting most things just fine without using their recommended file structure. It was only css imports that were not working.**
Whenever a import css from an npm package, I get the following error:
W20161023-13:23:17.701(-4)? (STDERR) /Users/mattmacpherson/Code/project/node_modules/codemirror/lib/codemirror.css:3
W20161023-13:23:17.701(-4)? (STDERR) .CodeMirror {
W20161023-13:23:17.701(-4)? (STDERR) ^
W20161023-13:23:17.702(-4)? (STDERR)
W20161023-13:23:17.702(-4)? (STDERR) SyntaxError: Unexpected token .
W20161023-13:23:17.703(-4)? (STDERR) at exports.runInThisContext (vm.js:53:16)
W20161023-13:23:17.703(-4)? (STDERR) at Module._compile (module.js:373:25)
W20161023-13:23:17.704(-4)? (STDERR) at Object.Module._extensions..js (module.js:416:10)
W20161023-13:23:17.704(-4)? (STDERR) at Module.load (module.js:343:32)
W20161023-13:23:17.704(-4)? (STDERR) at Module.Mp.load (/Users/mattmacpherson/.meteor/packages/babel-compiler/.6.9.1_1.15j1r1l++os+web.browser+web.cordova/npm/node_modules/reify/node/runtime.js:16:23)
W20161023-13:23:17.704(-4)? (STDERR) at Function.Module._load (module.js:300:12)
W20161023-13:23:17.704(-4)? (STDERR) at Module.require (module.js:353:17)
W20161023-13:23:17.705(-4)? (STDERR) at require (internal/module.js:12:17)
W20161023-13:23:17.705(-4)? (STDERR) at npmRequire (/Users/mattmacpherson/Code/project/.meteor/local/build/programs/server/npm-require.js:129:10)
W20161023-13:23:17.705(-4)? (STDERR) at Module.Mp.useNode (packages/modules-runtime/modules-runtime.js:69:1)
The example above is when importing codemirror's css but I also get the same error with many other packages, including react-s-alert and medium-draft.
Here is my .babelrc file:
{
"plugins": [
"transform-class-properties"
],
"presets": [
"babel-preset-es2015",
"babel-preset-react",
"babel-preset-stage-2"
]
}

bookshelf and knex initialization error

I am trying to setup a mysql connection in node js using bookshelf and knex. This is my setup:
var knex = require('knex')({
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'my_user',
password : 'my_password',
database : 'my_db',
charset : 'utf8'
}
});
var DB = require('bookshelf')(knex);
module.exports.DB = DB;
I get the following error:
Error: [object KnexClient] is not a valid Knex client, did you misspell it?
at new Knex (/Users/arenduchintala/Projects/MacaronicWebApp/node_modules/bookshelf/node_modules/knex/knex.js:48:17)
at new Bookshelf (/Users/arenduchintala/Projects/MacaronicWebApp/node_modules/bookshelf/bookshelf.js:43:14)
at Bookshelf (/Users/arenduchintala/Projects/MacaronicWebApp/node_modules/bookshelf/bookshelf.js:37:14)
at Object.<anonymous> (/Users/arenduchintala/Projects/MacaronicWebApp/db.js:11:37)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/arenduchintala/Projects/MacaronicWebApp/model.js:1:72)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
Looks like the line : require('bookshelf')(knex) throws an error.
I had an old version of bookshelf, I changed it in package.json from:
"bookshelf" : "0.5" to "bookshelf" : "*" and it seems to work now.
run
npm i --s mysql
it requires this package

grunt karma | Jasmine.js tasks issue

After running grunt karma, getting below error, the only change which I made, was upgrading the node packages.
"grunt-contrib-jasmine": "~0.8.2",
"karma": "~0.12.36",
"karma-chrome-launcher": "~0.1.12",
"karma-firefox-launcher": "~0.1.6",
"karma-jasmine": "~0.3.5",
"karma-phantomjs-launcher": "^0.2.0",
Error which I am getting after running Grunt Karma.
Loading "jasmine.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "jsdoc-plugin.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "grunt-karma.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "notify.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "notify_hooks.js" tasks...ERROR
>> TypeError: Cannot read property 'hooker' of undefined
Loading "open.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "shell.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "uncss.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "usemin.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Loading "GruntFile.js" tasks...ERROR
>> TypeError: Cannot read property '_' of undefined
Warning: Cannot read property 'name' of undefined Use --force to continue.
TypeError: Cannot read property 'name' of undefined
at Object.<anonymous> (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt/task.js:224:24)
at Object.<anonymous> (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:301:30)
at Task.runTaskFn (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:251:24)
at Task.<anonymous> (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:300:12)
at Task.start (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:309:5)
at Object.grunt.tasks (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt.js:164:8)
at Object.module.exports [as cli] (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt/cli.js:38:9)
at Object.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:45:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
Aborted due to warnings.
Fatal error: Cannot read property 'exit' of undefined
TypeError: Cannot read property 'exit' of undefined
at Object.fail.warn (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt/fail.js:73:15)
at Object.task.options.error (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt.js:137:12)
at Task.<anonymous> (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:221:29)
at Task.runTaskFn (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:257:7)
at Task.<anonymous> (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:300:12)
at Task.start (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:309:5)
at Object.grunt.tasks (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt.js:164:8)
at Object.module.exports [as cli] (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt/cli.js:38:9)
at Object.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:45:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt/fail.js:57
grunt.util.exit(typeof errcode === 'number' ? errcode : fail.code.FATAL_ERRO
^
TypeError: Cannot read property 'exit' of undefined
at Object.fail.fatal (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt/fail.js:57:13)
at process.uncaughtHandler (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt.js:130:10)
at process.emit (events.js:107:17)
at process._fatalException (node.js:236:26)
at Task.runTaskFn (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:257:7)
at Task.<anonymous> (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:300:12)
at Task.start (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/util/task.js:309:5)
at Object.grunt.tasks (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt.js:164:8)
at Object.module.exports [as cli] (/Users/marif/Dev/JavaScript/JavaScript-Boilerplate/node_modules/grunt/lib/grunt/cli.js:38:9)
at Object.<anonymous> (/usr/local/lib/node_modules/grunt-cli/bin/grunt:45:20)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
Hope to get some pointers to resolve the same.
P.S. It's been running fine if I use karma using 'karma start test/karma.conf.js' from the terminal. But I have been trying to kick off karma through grunt-karma task as well and that's where it's failing.

Resources