arunoda / meteor-up-legacy

Production Quality Meteor Deployments
MIT License
2.26k stars 394 forks source link

mup failing with Error: spawn ENOENT since 0.10.8 #609

Open ClarenceL opened 9 years ago

ClarenceL commented 9 years ago

I have this problem since 0.10.8, I've reverted back to 0.10.7 and it works, so my directories are named correctly.

| => node -v v0.10.36

`Meteor Up: Production Quality Meteor Deployments

“ Checkout Kadira! It's the best way to monitor performance of your app. Visit: https://kadira.io/mup

Building Started: /Users/zzzzzzzz/workspace/zzzzz-mobile/mobile

events.js:72 throw er; // Unhandled 'error' event ^ Error: spawn ENOENT at errnoException (child_process.js:1011:11) at Process.ChildProcess._handle.onexit (child_process.js:802:34)


| ~/workspace/zzzzz-mobile/mobile @ Clarences-MacBook-Pro (zzzzzzzz) | => sudo npm install -g mup@0.10.7 | ~/workspace/zzzzz-mobile/mobile @ Clarences-MacBook-Pro (zzzzzzzz) | => mup deploy

Meteor Up: Production Quality Meteor Deployments

“ Checkout Kadira! It's the best way to monitor performance of your app. Visit: https://kadira.io/mup

Building Started: /Users/zzzzzzzz/workspace/zzzzz-mobile/mobile The Android platform is not installed; skipping build for it.

Started TaskList: Deploy app 'zzzzz-mobile' (linux) [xxx.xxx.xxx.xxx] - Uploading bundle [xxx.xxx.xxx.xxx] - Uploading bundle: SUCCESS [xxx.xxx.xxx.xxx] - Setting up Environment Variables [xxx.xxx.xxx.xxx] - Setting up Environment Variables: SUCCESS [xxx.xxx.xxx.xxx] - Invoking deployment process [xxx.xxx.xxx.xxx] - Invoking deployment process: SUCCESS `

cryptoquick commented 9 years ago

I've tried to match your environment, but unfortunately, I'm still getting the same error you had, even with mup 0.10.7. I'm wondering if the way you solved this was related to something else?

# mup deploy

Meteor Up: Production Quality Meteor Deployments
------------------------------------------------

“ Checkout Kadira!
  It's the best way to monitor performance of your app.
  Visit: https://kadira.io/mup ”

Building Started: /root/zoomlisting

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: spawn ENOENT
    at errnoException (child_process.js:1011:11)
    at Process.ChildProcess._handle.onexit (child_process.js:802:34)

I'm using node 0.10.36, ubuntu 14.04, and mup 0.10.7.

cryptoquick commented 9 years ago

Also, I tried looking at the logs, but unfortunately, this is what comes up:

[x.x.x.x] tail: cannot open ‘/var/log/upstart/xxx.log’ for reading[x.x.x.x] : No such file or directory
MasterJames commented 9 years ago

Maybe check if upstart is installed via? initctl --version

cryptoquick commented 9 years ago

Yep, upstart is installed.

MasterJames commented 9 years ago

Does the path to the log file that's missing exist too? /var/log/upstart/*.log try... mkdir -p /var/log/upstart are permissions okay?

cryptoquick commented 9 years ago

Yep, I tried that, no dice.

root@xxx:~/xxx# mupx deploy

Meteor Up: Production Quality Meteor Deployments
------------------------------------------------
Configuration file : mup.json
Settings file      : settings.json

“ Checkout Kadira!
  It's the best way to monitor performance of your app.
  Visit: https://kadira.io/mup ”

Meteor app path    : /root/xxx
Using buildOptions : {}
events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: spawn meteor ENOENT
    at exports._errnoException (util.js:746:11)
    at Process.ChildProcess._handle.onexit (child_process.js:1053:32)
    at child_process.js:1144:20
    at process._tickCallback (node.js:355:11)
    at Function.Module.runMain (module.js:503:11)
    at startup (node.js:129:16)
    at node.js:814:3

I switched to mupx, and I'm still seeing this message.

KristerV commented 9 years ago

Once again looking at this error.. this time though I've made ultra-sure the app path is correct (https://github.com/arunoda/meteor-up/issues/405)

Using mupx 2.14.2.

cryptoquick commented 9 years ago

Yeah, I was still seeing this when I tried deploying on DO. I'm thinking either of trying a different VPS provider or manually using a Docker container.

KristerV commented 9 years ago

I got mine fixed when tried to just run the app with meteor, the way you would on your local machine. Turned out I hadn't set my locale and MongoDB couldn't start. I suggest you run meteor too.

MasterJames commented 9 years ago

Most people have had app path issues relating to this ENOENT ("no file or directory") error. Usually it's wrong or not fully qualified, maybe permissions, etc?

ClarenceL commented 9 years ago

Ya tried every version of the, even a relative one. Permissions, maybe if under the hood it was running under a different user, but sudo didn't work either.

I now have this issue again with Meteor 1.2

ClarenceL commented 9 years ago

I found a workaround, and it's a pain, so here goes - it involves hacking your mup files a bit each time unfortunately.

look in build.js - line 34 is the culprit

var meteor = spawn(executable, args, options );

if you console log that you will see

/usr/local/bin/meteor --debug [ 'build',
  '--directory',
  '/var/folders/g2/sjmmz3w13q54sgwfbwnxjh_00000gn/T/58659e57-d261-4e29-9db1-d52f1b586f8c',
  '--server',
  'http://localhost:3000' ] { pwd: '/Users/clarencel/workspace/liveaudit/liveaudit/' }

If you know the NodeJS spawn function, basically it's calling:

/usr/local/bin/meteor --debug build --directory /var/folders/g2/sjmmz3w13q54sgwfbwnxjh_00000gn/T/58659e57-d261-4e29-9db1-d52f1b586f8c --server http://localhost:3000

With the options set to {cwd: Your mup.json 'app' field}

Now here's the weird part! I can go to my app directory, and run that command directly and it works!


Ok so how do we get it to work? Basically every time mup starts it'll build the bundle in that directory, now, each time that folder is different: actions.js - line 104

var buildLocation = path.resolve(os.tmpdir(), uuid.v4());

It uses a uuid.v4(), your os.tmpdir() shouldn't change so you can leave that alone, but change the uuid.v4() to something static, I used clarencel-meteor

Literally hacking

// use whatever static folder you want
var buildLocation = path.resolve(os.tmpdir(), 'clarencel-meteor');

Ok now save that file, then go to your command line, from your app directory, run that command earlier to bundle it, but this time use your folder name

/usr/local/bin/meteor --debug build --directory /var/folders/g2/sjmmz3w13q54sgwfbwnxjh_00000gn/T/clarencel-meteor --server http://localhost:3000

That should work, and hey if it doesn't, it'll tell you exactly why the build didn't work! I actually had accidentally added the android platform, and didn't have ANDROID_HOME setup, so I just removed that platform, alas mup didn't work, so must be something else. But I didn't dwell on that much longer, who cares if I can get that above command to bundle, I'm set.

Ok so now you have the bundle built and in that folder

Now I hacked mup, to NOT build the bundle

build.js - line ~30

  // comment all this out
  /*
  var options = {cwd: appPath};
  var meteor = spawn(executable, args, options);
  var stdout = "";
  var stderr = "";

  meteor.stdout.pipe(process.stdout, {end: false});
  meteor.stderr.pipe(process.stderr, {end: false});

  meteor.on('close', callback);
  */
  callback(0);

Normally it'll spawn the process call meteor build, wait for it to finish and then call the callback, 0 on success. So we'll just skip straight to that.

If you followed this properly it should work now, or at least you can run the build process separately and troubleshoot there.

ClarenceL commented 9 years ago

If there's something I can test to see why that command works directly in the term, but not through NodeJS's spawn that'd be awesome. I'm on v0.10.40 too.

MasterJames commented 9 years ago

You can use SSH to access the deployment server and execute manually stepping through the scripts etc to track down errors.

ClarenceL commented 9 years ago

I've narrowed it down the to the debug switch, in the term:

/usr/local/bin/meteor --debug build --directory /var/folders/g2/sjmmz3w13q54sgwfbwnxjh_00000gn/T/58659e57-d261-4e29-9db1-d52f1b586f8c --server http://localhost:3000

works, however in mup the --debug flag there breaks it, maybe the order, it should come after build? But I don't have access to the spawn args array.

ClarenceL commented 9 years ago

Verified it is the order of build and --debug, so apparently before Meteor 1.2 - I could put in the mup.json

"meteorBinary": "/usr/local/bin/meteor --debug"

However now that no longer works for some reason, I have added a pull request to mup, for the debug flag, which I added, setting "debug": true, will achieve the same thing now.

MasterJames commented 9 years ago

It could be disabling ECMAScript works to help here, but it will eventually be fixed (by meteor I belive) so updating meteor should eventually fix this problem.