Foreman start hangs - node.js

I'm trying to make an express (currently working) application to work with foreman start.
This is my Procfile:
web: node ./bin/www
This is my www file:
#!/usr/bin/env node
var debug = require('debug')('quiz');
var app = require('../app');
app.set('port', process.env.PORT || 3000);
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
And this is my package.json:
{
"name": "quiz",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"engines": {
"node": "0.10.x",
"npm": "1.4.x"
},
"devDependencies": {
"sqlite3": "^3.0.8"
},
"dependencies": {
"body-parser": "~1.8.1",
"cookie-parser": "~1.3.3",
"debug": "~2.0.0",
"ejs": "~0.8.5",
"express": "~4.9.0",
"express-partials": "^0.3.0",
"morgan": "~1.3.0",
"pg": "^4.1.1",
"pg-hstore": "^2.3.2",
"sequelize": "^1.7.0",
"serve-favicon": "~2.1.3"
}
}
When I run foreman start in the log everything looks alright:
23:17:21 web.1 | started with pid 1632
When I test it in my browser the request are shown in the log but nothing reach the browser.
This is de log when I try to browse to http://localhost:5000/:
23:20:56 web.1 | ←[0mGET / ←[32m200 ←[0m25.741 ms - 1404←[0m
23:20:56 web.1 | ←[0mGET /stylesheets/style.css ←[36m304 ←[0m5.098 ms - -←[0m
23:20:56 web.1 | ←[0mGET /stylesheets/wide.css ←[36m304 ←[0m4.419 ms - -←[0m
The request seems to be resolved but the browser keeps waiting for response indefinitely. Finally the browser shows ERR_EMPTY_RESPONSE.
I try to make some other arbitrary request with the same result:
23:23:08 web.1 | ←[0mGET /author ←[32m- ←[0m- ms - -←[0m
23:23:08 web.1 | ←[0mGET /stylesheets/smartphone.css ←[32m- ←[0m- ms - -←[0m
23:25:59 web.1 | ←[0mGET /author ←[32m- ←[0m- ms - -←[0m
23:28:00 web.1 | ←[0mGET /author ←[32m- ←[0m- ms - -←[0m
23:30:00 web.1 | ←[0mGET /author ←[32m- ←[0m- ms - -←[0m
Any idea of how could I debug this in order to figure what's happening?
Thanks in advance.

Heroku no longer supports foreman so the best approach would be to try using their recommended alternative to foreman instead: the heroku command "local".
The implementation is trivial:
Download and install the latest version of heroku toolbelt (which no longer includes foreman).
Instead of using foreman start use heroku local.
See heroku's web site for full details of heroku local.
Although you don't mention it, is it possible that the reason you are getting those ERR_EMPTY_RESPONSE messages is because foreman had died (rather than "hung") while handling the request? I had the same problem with some stylesheets after foreman had logged the message "sending SIGKILL to all processes" to the console, and terminated. Regardless, my problems vanished when I used heroku local instead of foreman start.
And even if heroku local also fails, that should become the issue to resolve rather than your current problem with foreman.

Related

Errors deploying node elastic beanstalk application

When deploying my new elastic beanstalk, Node.js 12 running on 64bit Amazon Linux 2/5.2.2, application, I'm getting error after running $ eb deploy myapp-staging-env:
2020-10-17 19:57:56 INFO Environment update is starting.
2020-10-17 19:58:22 INFO Deploying new version to instance(s).
2020-10-17 19:58:49 ERROR Instance deployment failed. For details, see 'eb-engine.log'.
2020-10-17 19:58:49 ERROR [Instance: i-034b2f1000000] Command failed on instance. Return code: 1 Output: Engine execution has encountered an error..
2020-10-17 19:58:49 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2020-10-17 19:58:49 ERROR Unsuccessful command execution on instance id(s) 'i-034b2f1d46f466259'. Aborting the operation.
2020-10-17 19:58:50 ERROR Failed to deploy application.
I don't really know where to start.
Errors from logs:
Web.stdout.log: where do I go to fix this error?
----------------------------------------
/var/log/web.stdout.log
----------------------------------------
Oct 17 17:31:43 ip-172-31-47-6 web: Server running at http://127.0.0.1:8080/
...
Oct 17 19:58:50 ip-172-31-47-6 web: /bin/sh: -c: line 0: syntax error near unexpected token `('
Oct 17 19:58:50 ip-172-31-47-6 web: /bin/sh: -c: line 0: `node app.js%!(EXTRA string=server.js)'
Engine execution has encountered an error: what does this mean?
2020/10/17 19:58:49.360716 [INFO] Executing cleanup logic
2020/10/17 19:58:49.360804 [INFO] CommandService Response: {"status":"FAILURE","api_version":"1.0","results":[{"status":"FAILURE","msg":"Engine execution has encountered an error.","returncode":1,"events":[{"msg":"Instance deployment failed. For details, see 'eb-engine.log'.","timestamp":1602964729,"severity":"ERROR"}]}]}
2020/10/17 19:58:49.360984 [INFO] Platform Engine finished execution on command: app-deploy
Execution error on command [app-deploy]: where do I go to fix this?
2020/10/17 19:58:49.339070 [INFO] Running command /bin/sh -c systemctl start web.service
2020/10/17 19:58:49.360702 [ERROR] An error occurred during execution of command [app-deploy] - [FlipApplication]. Stop running the command. Error: Register application failed because the registration of proc web failed:
startProcess Failure: starting process "web" failed: Command /bin/sh -c systemctl start web.service failed with error exit status 1. Stderr:Job for web.service failed because the control process exited with error code. See "systemctl status web.service" and "journalctl -xe" for details.
My package.json:
{
"name": "api",
"version": "0.0.0",
"private": true,
"engines": {
"node" : "12.18.0"
},
"scripts": {
"initialize": "knex migrate:latest && knex seed:run",
"reset": "node_modules/.bin/knex migrate:rollback && node_modules/.bin/knex migrate:latest && node_modules/.bin/knex seed:run",
"initialize-prod": "node_modules/.bin/knex migrate:latest --env production && node_modules/.bin/knex seed:run --env production",
"reset-prod": "node_modules/.bin/knex migrate:rollback --env production && node_modules/.bin/knex migrate:latest --env production && node_modules/.bin/knex seed:run --env production",
"start": "node -v && node server.js",
"server": "node -v && nodemon server.js",
"server-debug": "nodemon --inspect=0.0.0.0 server.js",
"test": "mocha"
},
"dependencies": {
"#google-cloud/speech": "^3.5.4",
"#google-cloud/translate": "^5.1.4",
"body-parser": "^1.18.3",
"bookshelf": "^0.13.3",
"cookie-parser": "~1.4.3",
"cors": "^2.8.4",
"debug": "~2.6.9",
"dotenv": "^7.0.0",
"ejs": "~2.5.7",
"event-stream": "^3.3.5",
"express": "~4.16.0",
"fs": "0.0.1-security",
"fs-path": "0.0.24",
"knex": "^0.20.8",
"lodash": "^4.17.15",
"mailgun-js": "^0.22.0",
"moment": "^2.22.2",
"morgan": "^1.9.1",
"nock": "^10.0.6",
"node-gyp": "^7.1.2",
"passport": "^0.4.0",
"passport-cookie": "^1.0.6",
"pg": "^7.5.0",
"request": "^2.88.0",
"request-promise": "^4.2.2",
"swagger-jsdoc": "^4.0.0",
"swagger-ui-express": "^4.1.4"
},
"devDependencies": {
"chai": "^4.2.0",
"mocha": "^6.2.0",
"nodemon": "^1.18.4"
}
}
Also, for a previous node app I launched (last year), I was able to modify gzip compression and specify the node command, but this option is no longer available:
Elastic Beanstalk removed NodeCommand from software config in favor of a Procfile.
From updated AWS docs on EB Node Deployment:
You can add a Procfile to your source bundle to specify the command
that starts your application, as the following example shows. This
feature replaces the legacy NodeCommand option in the
aws:elasticbeanstalk:container:nodejs namespace.
The Procfile is added to the application root and contains your app run script, e.g.:
web: node server.js
I redeployed and it solved the deploy error (unsure about the Web.stdout.log and app-deploy errors above).

Error : Cannot find Module 'fabric-client' in fabric 1.2

Even after trying "npm update" command, still i am facing fabric-client error. The error details given below
Fabric version - 1.2 |
OS - Amazon Linux2 |
command - npm i
[root#ip-172-31-61-27 controller]# node app.js
module.js:538
throw err;
^
Error: Cannot find module 'fabric-client'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/ec2-user/AWSNodeApp/controller/app.js:27:11)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
Below is the content of package.json
{
"name": "awsnodeapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"aws-sdk": "^2.538.0",
"body-parser": "^1.17.1",
"cors": "^2.8.3",
"express": "^4.15.2",
"express-session": "^1.15.2",
"fabric-ca-client": "1.3.0",
"fabric-client": "1.3.0",
"fs-extra": "^2.0.0",
"log4js": "^3.0.6",
"uuid": "^3.3.2",
"ws": "^6.1.0"
}
}
That looks like the kind of error you get if you haven't actually downloaded your project dependencies with npm install prior to running your application. Or have not included a dependency required by your code in your project's package.json. Or possibly the npm install failed to download the dependencies due to connectivity issues accessing the npm registry. Either way, if you don't have a node_modules/fabric-client directory within your project directory, you haven't downloaded your required dependency.
The fabric-client#1.2 package definitely exists: https://www.npmjs.com/package/fabric-client/v/1.2.2
Note that this version of Hyperledger Fabric is obsolete. As of today (August 2020), you really should be using v1.4 or (ideally) v2.2. Note that the Node SDK has changed with the v2.2 release and, although the v1.4 fabric-client package will still work with a v2.2 Fabric, it is recommended to use fabric-network#2.2: https://hyperledger.github.io/fabric-sdk-node/release-2.2/tutorial-migration.html
fabric client module is not installed in your project. try this command to install fabric-client module
npm i fabric-client

Cannot find module './mergeConfig' when running on Heroku

I have a node application that runs fine when executed on my machine via node my_application.js.
However, if push it to heroku and execute it via heroku run node my_application.js or with the scheduler what I get is this error:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module './mergeConfig'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/app/node_modules/axios/lib/core/Axios.js:7:19)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
I'm running node v10.16.0 and npm v6.9.0 both locally and on Heroku, so I really don't know what may be causing this issue, and googling for it didn't help in any way.
Any ideas about this mergeConfig module that seems to be missing from my heroku environment but not from my local environment?
Edit: this is my package.json:
{
"name": "[REDACTED]",
"version": "1.0.0",
"description": "[REDACTED]",
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.0",
"bluebird": "^3.5.3",
"body-parser": "^1.18.3",
"dateformat": "^3.0.3",
"express": "^4.16.4",
"form-data": "^2.3.3",
"http-to-curl": "^1.4.2",
"jest": "^24.8.0",
"qs": "^6.6.0",
"querystring": "^0.2.0",
"redis": "^2.8.0",
"simple-oauth2": "^2.2.1"
}
}
Try to add explicitly the missing module in the dependencies in package.json:
"dependencies": {
...
"merge-config" :"2.0.0"
...
}
I think it works on your local environment because you have the module installed globally.
I had the same problem.
'./mergeConfig' is a file inside de axios module.
Path: node_modules/axios/core/mergeConfig.js
For some reason heroku had a problem with this file.
I solved it by replacing axios with request.
This fixed the problem for me NODE_OPTIONS=--max_old_space_size=4096
src: https://github.com/axios/axios/issues/1767#issuecomment-416924946

React-native App fails to launch in Android with multiple warning messages on debug builds

Environment
react-native-cli: 2.0.1, node : v8.2.1, npm: 5.3.0,
Target Platform:
Android 5.0 x86-64 image
Development Operating System:
Windows 7 professional edition, x86_64
package.json
"dependencies": {
"axios": "^0.16.2",
"buffer": "^5.0.6",
"lodash": "^4.17.4",
"mobx": "^3.2.1",
"mobx-react": "^4.2.2",
"react": "16.0.0-alpha.12",
"react-native": "0.45.1",
"react-native-background-timer": "^1.1.0",
"react-native-fetch-blob": "latest",
"react-native-timer": "^1.3.1"
},
"devDependencies": {
"babel-jest": "20.0.3",
"babel-preset-react-native": "2.0.0",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12",
"tslint": "^5.4.3",
"typescript": "^2.4.1",
"typings": "^2.1.1"
},
Steps to Reproduce
npm install, npm run build, react-native run-android
Expected Behavior
This is supposed to launch the application successfully on Physical device connected via USB or on the emulator running.
Actual Behavior
App fails to launch with these bunch of warning messages:
Warning: Failed prop type: Invalid prop 'alignItems' of value 'function checkType() {... [native code]
Warning: Failed prop type: Invalid prop 'bacckgroundColor' supplied to 'SrollView': function colorPropType() { [native code] }
Warning: Failed prop type: Invalid prop 'bacckgroundColor' supplied to 'View': function colorPropType() { [native code] }
Warning: Failed prop type: Invalid prop 'display' of type 'function' supplied to 'RCTView', expected 'string'. Bad object:{} in RCTView (at View.js:128)
....
Build and deployment works fine with release builds which means running the following command it works fine:
react-native run-android --variant=release
2) The same code base doesn’t work with apk debug builds
react-native run-android --variant=debug
3) The weird thing is that this behavior is not consistent. Intermittently sometimes it works fine. For example, I have tried using different combination of react/react-native versions in the package.json. Its observed that it worked once with react v0.47.1 and react-native v16.0.0-bet5. The same configuration on same set up failed later.
4) For once it also worked with a combination of both react/react-native upgraded to latest versions (v0.48_rc0 and v16.0.0-bet5 respectively). But that too is not consistently working.

hubot-slack throwing an error on startup

I am trying to add a new hubot integration to our Slack channels. I am setting this up on a Windows machine and am deploying to a Heroku server. I followed the installation instructions provided here: https://github.com/slackhq/hubot-slack
I can create and run a new hubot instance on my local computer (calling "bin/hubot" in a Powershell prompt), but when I install the hubot-slack package and add "hubot-slack" to the external-scripts file I get an error. If I remove the value from the external-scripts file everything is fine.
PS C:\hubot> bin/hubot
jarvis> [Tue Dec 22 2015 15:18:24 GMT-0800 (Pacific Standard Time)] ERROR Error loading scripts from npm package - TypeError: require(...) is not a function
at Robot.loadExternalScripts (C:\hubot\node_modules\hubot\src\robot.coffee:399:11)
at C:\hubot\node_modules\hubot\bin\hubot:128:26
at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
If I include the adapter flag for Slack I get a different error. I tried setting HUBOT_SLACK_TOKEN as a System Environment variable.
PS C:\hubot> bin/hubot -a slack
[Tue Dec 22 2015 15:21:54 GMT-0800 (Pacific Standard Time)] ERROR No services token provided to Hubot
Every example I can find is including the HUBOT_SLACK_TOKEN in the call to hubot, but it doesn't work for me (I must be missing something).
PS C:\hubot> HUBOT_SLACK_TOKEN=xoxb-22211110000-123456781234ZZZZYYYYXXXX ./bin/hubot --adapter slack
HUBOT_SLACK_TOKEN=xoxb-17240119159-dBeAEc2X8M2O9vJBYzWj5KFW : The term
'HUBOT_SLACK_TOKEN=xoxb-17240119159-dBeAEc2X8M2O9vJBYzWj5KFW' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is
correct and try again.
At line:1 char:1
+ HUBOT_SLACK_TOKEN=xoxb-22211110000-123456781234ZZZZYYYYXXXX ./bin/hubot --adapte ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (HUBOT_SLACK_TOK...234ZZZZYYYYXXXX:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
To rule out something locally I deployed the application to Heroku, but I got a different error.
2015-12-22T22:28:49.426496+00:00 heroku[web.1]: State changed from crashed to starting
2015-12-22T22:14:54.739959+00:00 heroku[web.1]: State changed from starting to up
2015-12-22T22:14:55.133113+00:00 app[web.1]: [Tue Dec 22 2015 22:14:55 GMT+0000 (UTC)] ERROR Error loading scripts from npm package - TypeError: object is not a function
2015-12-22T22:14:55.133117+00:00 app[web.1]: at Robot.loadExternalScripts (/app/node_modules/hubot/src/robot.coffee:399:11, <js>:269:39)
2015-12-22T22:14:55.133119+00:00 app[web.1]: at fs.js:272:14
2015-12-22T22:14:55.133121+00:00 app[web.1]: at Object.oncomplete (fs.js:108:15)
2015-12-22T22:14:56.115333+00:00 heroku[web.1]: State changed from up to crashed
package.json:
{
"name": "jarvis",
"version": "0.0.0",
"private": true,
"author": "Me <email#domain.com>",
"description": "A friendly robot",
"dependencies": {
"hubot": "^2.17.0",
"hubot-diagnostics": "0.0.1",
"hubot-google-images": "^0.2.6",
"hubot-google-translate": "^0.2.0",
"hubot-help": "^0.1.2",
"hubot-heroku-keepalive": "^1.0.1",
"hubot-maps": "0.0.2",
"hubot-pugme": "^0.1.0",
"hubot-redis-brain": "0.0.3",
"hubot-rules": "^0.1.1",
"hubot-scripts": "^2.16.2",
"hubot-shipit": "^0.2.0",
"requirejs": "^2.1.22",
"hubot-slack": "^3.4.2"
},
"engines": {
"node": "0.10.x"
}
}
external-scripts.json
[
"hubot-diagnostics",
"hubot-help",
"hubot-heroku-keepalive",
"hubot-google-images",
"hubot-google-translate",
"hubot-pugme",
"hubot-maps",
"hubot-redis-brain",
"hubot-rules",
"hubot-shipit",
"requirejs",
"hubot-slack"
]
On Windows, it seems that the mechanism is a little different from what it processes in Linux. The error 'HUBOT_SLACK_TOKEN is not recognized' is raised because it would read the value of 'HUBOT_SLACK_TOKEN' from environment variables in windows.
Create an environment variable 'HUBOT_SLACK_TOKEN' manually and set the value, it will work.
You could check it out in the source code in the github repo: slack.coffee.
options =
token: process.env.HUBOT_SLACK_TOKEN
autoReconnect: !exitProcessOnDisconnect
autoMark: true
exitOnDisconnect: exitProcessOnDisconnect
proxyUrl: process.env.https_proxy
What intrigues me is this particular line:
Error loading scripts from npm package - TypeError: require(...) is not a function
Did you add the other scripts from the repo aswell?
There also might be something wrong with the node/npm/coffee installation/version on your windows machine. Make sure that those are installed and in a compatible version. Another thread had an issue with incompatible versions. Please tell us about the versions you use and try downgrading node to 0.12.x.
The way you use the token is fine.

Resources