Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errored but no information (coffee script?) #488

Closed
binarykitchen opened this issue May 27, 2014 · 27 comments
Closed

Errored but no information (coffee script?) #488

binarykitchen opened this issue May 27, 2014 · 27 comments

Comments

@binarykitchen
Copy link
Contributor

I have an app here I cannot start with pm2. pm2 list always says errored and there is no additional information why. Log files tell me nothing.

How should I examine the error??

@binarykitchen
Copy link
Contributor Author

Hmmm, when I try to start the app many times after a delete, sometimes I can spot these log lines. But they do not make much sense to me:

[server-3 (err) 2014-05-28T00:27:26]  Object.Module._extensions..js (module.js:474:10)
[server-3 (err) 2014-05-28T00:27:26]   at Module.load (/opt/node-0.10.28/lib/node_modules/pm2/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
[server-3 (err) 2014-05-28T00:27:26]   at Function.Module._load (module.js:312:12)
[server-3 (err) 2014-05-28T00:27:26]   at Module.require (module.js:364:17)
[server-3 (err) 2014-05-28T00:27:26]   at require (module.js:380:17)
[server-3 (err) 2014-05-28T00:27:26]   at Object.<anonymous> (/var/www/nzslcomposer/server/server.js:7:23)
[server-3 (err) 2014-05-28T00:27:26]   at Module._compile (module.js:456:26)
[server-3 (err) 2014-05-28T00:27:26]   at Object.Module._extensions..js (module.js:474:10)
[server-3 (err) 2014-05-28T00:27:26]   at Module.load (/opt/node-0.10.28/lib/node_modules/pm2/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
[server-3 (err) 2014-05-28T00:27:26]   at Function.Module._load (module.js:312:12)
[server-3 (err) 2014-05-28T00:27:26]   at Module.require (module.js:364:17)
[server-3 (err) 2014-05-28T00:27:26]   at require (module.js:380:17)
[server-3 (err) 2014-05-28T00:27:26]   at /opt/node-0.10.28/lib/node_modules/pm2/lib/ProcessContainer.js:159:5
[server-3 (err) 2014-05-28T00:27:26]   at WriteStream.<anonymous> (/opt/node-0.10.28/lib/node_modules/pm2/lib/ProcessContainer.js:104:9)
[server-3 (err) 2014-05-28T00:27:26]   at WriteStream.EventEmitter.emit (events.js:95:17)
[server-3 (err) 2014-05-28T00:27:26]   at WriteStream.<anonymous> (fs.js:1662:10)
[server-3 (err) 2014-05-28T00:27:26]   at Object.oncomplete (fs.js:107:15)

A bug related to coffee script in the pm2 module?

@binarykitchen binarykitchen changed the title Errored but no information Errored but no information (coffee script?) May 27, 2014
@Unitech
Copy link
Owner

Unitech commented May 27, 2014

Start your app in fork mode with the -x option

@binarykitchen
Copy link
Contributor Author

@Unitech Why?

@binarykitchen
Copy link
Contributor Author

I do not want to lose pm2's core features ...

@soyuka
Copy link
Collaborator

soyuka commented May 27, 2014

Are you sure that your script runs with nodejs ?

@binarykitchen
Copy link
Contributor Author

@soyuka Oh yes, it runs with nodejs :)

@binarykitchen
Copy link
Contributor Author

@Unitech is already investigating this for me - I gave him access to the private repo ...

@binarykitchen
Copy link
Contributor Author

Any news on this one @soyuka ??

@soyuka
Copy link
Collaborator

soyuka commented Jun 12, 2014

Could you try using node v11.10?
Does it work with -x option? (I know you don't want to lose pm2 features - just to test if same error is throwed)
Could you enable export DEBUG="pm2:*" and run it with --no-daemon option?

Thanks.

@binarykitchen
Copy link
Contributor Author

Thanks man - I just gave you access to that private repo. Clone it and check it out yourself, thanks :)

@binarykitchen
Copy link
Contributor Author

For reasons I cannot explain, it works now in cluster mode. No idea why. Probably one of your recent updates has fixed it. Closed for now.

Many thanks for your time anyway!

@ghost
Copy link

ghost commented Dec 19, 2014

It worked for me in the version 0.12.1 but when i updated to 0.12.2 it stopped working guess its some issue in your update

@kylefinley
Copy link
Contributor

@aashrairavooru, I'm seeing the same. Looks like regression?

@Tjatse
Copy link
Collaborator

Tjatse commented Dec 24, 2014

Any sample code (simplify) to help me reproducing this issue?

@Tjatse Tjatse reopened this Dec 24, 2014
@kylefinley
Copy link
Contributor

@Tjatse,

Awesome project, I wish I would have found it earlier, thank you for helping out with this.

Here's a repo:
https://github.com/kylefinley/PM2-coffee-test

And a description of the problem:
https://raw.githubusercontent.com/kylefinley/PM2-coffee-test/master/README.md

Please let me know if there's anything else I can do.

@Tjatse
Copy link
Collaborator

Tjatse commented Dec 24, 2014

@kylefinley
You must specific the interpreter to coffee when you're using PM2 to run the coffee-script in a fork-mode, e.g.:

$ pm2 start server.coffee --interpreter coffee

But coffee interpreter will be invoked automatically if you run your coffee-script in a cluster-mode, 'Cause coffee-script module provides a hacked stuff for chid_process.fork

What we do:

  if (p.extname(script) == '.coffee') {
    require('coffee-script/register');
  }

What coffee-script does in coffee-script/register.js:

  if (child_process) {
    fork = child_process.fork;
    binary = require.resolve('../../bin/coffee');
    child_process.fork = function(path, args, options) {
      if (helpers.isCoffee(path)) {
        if (!Array.isArray(args)) {
          options = args || {};
          args = [];
        }
        args = [path].concat(args);
        path = binary;
      }
      return fork(path, args, options);
    };
  }

kylefinley added a commit to kylefinley/PM2 that referenced this issue Dec 24, 2014
Coffee script requires the --interpreter coffee flag

Unitech#488 (comment)
@kylefinley
Copy link
Contributor

Thank you @Tjatse, that was very helpful. I appreciate the quick response.

I've submitted a pull request for an update to the documentation concerning coffee-script. #901

@Tjatse Tjatse closed this as completed Dec 24, 2014
@tusharmath
Copy link

I followed the same steps. But it is still giving SyntaxError.

@kylefinley
Copy link
Contributor

@tusharmath,

Are you seeing an error with this test repo:

https://github.com/kylefinley/PM2-coffee-test

If you so, could you try clearing your npm cache and reinstalling PM2:

rm -rf ~/.npm
npm cache clear
npm i -g pm2

@tusharmath
Copy link

@kylefinley Thanks for the quick response. I am not facing this issue in your repo. Its my own piece of code written in coffee which is creating this issue.

@kylefinley
Copy link
Contributor

@tusharmath, Good to know.

My suggestion would be to get it to work without PM2 i.e. coffee server.coffee first. We probably shouldn't discuss it here since the issue isn't related to PM2, but If you need some help you can contact me, my email is in my profile. Just upload the repo to Github and I'll take a look. Stack overflow is another good option.

@tusharmath
Copy link

@kylefinley
There isn't much code.

I have a file - tushar.coffee with only one line of code.

http = require 'http'

And I am running the following command - pm2 start tushar.coffee --interpreter=coffee

The following two log files are empty

 ~/.pm2/logs/tushar-out-2.log
 ~/.pm2/logs/tushar-error-2.log

@kylefinley
Copy link
Contributor

What's the error message that your seeing?

Also what's the log say:

pm2 logs

@tusharmath
Copy link

pm2 logs -
PM2: 2014-12-25 11:25:20: Starting execution sequence in -fork mode- for app name:tushar id:2
PM2: 2014-12-25 11:25:20: App name:tushar id:2 online
PM2: 2014-12-25 11:25:20: App name:tushar id:2 exited
PM2: 2014-12-25 11:25:20: Starting execution sequence in -fork mode- for app name:tushar id:2
PM2: 2014-12-25 11:25:20: App name:tushar id:2 online
PM2: 2014-12-25 11:25:21: App name:tushar id:2 exited
PM2: 2014-12-25 11:25:21: Script /Users/tusharmathur/Documents/Projects/pm2-issue/tushar.coffee had too many unstable restarts (15). Stopped. "errored"

update -

server-0 (err): /Users/tusharmathur/Documents/Projects/pm2-issue/tushar.coffee:2
server-0 (err): require 'http'
server-0 (err): ^^^^^^^^^^
server-0 (err): SyntaxError: Unexpected string
server-0 (err): at Module._compile (module.js:439:25)
server-0 (err): at Object.Module._extensions..js (module.js:474:10)
server-0 (err): at Module.load (module.js:356:32)
server-0 (err): at Function.Module._load (module.js:312:12)
server-0 (err): at Function.Module.runMain (module.js:497:10)
server-0 (err): at startup (node.js:119:16)
server-0 (err): at node.js:929:3

@kylefinley
Copy link
Contributor

@tusharmath , I'm not sure maybe someone else with more experience can help.
The only other thing I can think is that maybe a running tasks is causing problems. Try:

pm2 list

Then run pm2 delete for each of the running scripts e.g.

pm2 delete tushar

Since you said that my test repo was working for you, maybe you could use it for now as an entry point.

@tusharmath
Copy link

Thankyou for putting in so much of effort nevertheless!

@jfoclpf
Copy link

jfoclpf commented Jul 8, 2021

Just FYI that I'm using the latest version of PM2 and I was having exactly the some problem, the app was errored but no error log information was being thrown. I realized it had to do with the permissions of the log folder at ~/.pm2/logs/*

Since I'm running pm2 in a non-sudo user, but I install PM2 with sudo npm install pm2@latest -g, there is a mess in permissions in logs, so I changed the permissions of all the logs to myself and the problem is solved.

sudo chown my_user_name ~/.pm2/logs/* && sudo chgrp my_user_name ~/.pm2/logs/*

PM2 was trying to access the log files but it had no permission. Maybe PM2 should be more verbose on this error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants