Deploying a Meteor application from OS X on Linux causes bcrypt problems

I just deployed my first Meteor app, but ran into a pretty significant problem. When I tried to start my application, I get the following error:

/home/hiapp/bundle/programs/server/node_modules/fibers/future.js:173 throw(ex); ^ Error: /home/hiapp/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.require (module.js:364:17) at require (module.js:380:17) at bindings (/home/hiapp/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15) at Object.<anonymous> (/home/hiapp/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/bcrypt.js:1:97) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) 

In the course of some research, it seems that the problem is that bcrypt has specifics for the platform, and because my development refers to OS X 10.10, but my production server is on Ubuntu 14.04, that’s the problem. My job was to run npm install bcrypt from the program / server folder and then copy it from programs/server/node_modules/bcrypt to programs/server/npm . It looks like a lot of manual steps.

I'm going to redeploy my application with some fixes, and I'm worried that I will have to follow the same steps again. Is there a better way to deploy the Meteor app where you are not facing this problem? My procedure currently:

  • Run meteor build
  • scp result tarball for my server (Digital Ocean)
  • Explode tarball in application users home directory
  • ADDED STEPS: recompile bcrypt and copy the directory as described above.

I assume that auto-update will be broken as soon as the server first loads the new libraries, which will explode in fiery glory. Would it be better to just clone the GIT repository on the server and make a line right from there, or can I use mup or any other tools to help smooth the deployment process?

+6
source share
3 answers

I had the same problem - instead, I switched to using Meteor Up (MUP) and the problem disappeared. Not to mention that it is much easier!

I followed this youtube guide - https://www.youtube.com/watch?v=WLGdXtZMmiI , which covers deployment using MUP in Digital Ocean.

The MUP github page specifically mentions that it processes NPM binary modules - https://github.com/arunoda/meteor-up#binary-npm-module-support

Hope some help!

+2
source

There are two ways to get around this time-consuming issue, which depends entirely on how you deploy.

Manual deployment

If you are manually deploying your application, be sure to use node v0.10.36 1 and only that. Meteor does not work with node v0.12.x. More specifically, the fiber modulus causes many problems, it suffocates from various errors 2 .

Below is the procedure that fixed this for me 3, 4 :

  • Remove the bcrypt module from the npm directory:

     $ cd path_to_your_app/bundle/programs/server $ rm -rf npm/npm-bcrypt/node_modules/bcrypt/ 
  • First install the bcrypt module in the node_modules directory. This creates bcrypt for the server OS:

     $ npm install bcrypt 
  • Move the newly created bcrypt module to the npm directory:

     $ cp -r node_modules/bcrypt npm/npm-bcrypt/node_modules/bcrypt 
  • Finally, restart the application, mogodb, and any web server processes such as nginx 6 through the upstart if you configured it. Under the heading of the security steps below, you can complete it if the steps above did not fix it for you.

Using Meteor Up (mup)

If you use mup, the process is much simpler than other responses to this thread. However, there are cases where errors still occur, including an invalid ELF header error. Make sure you have the latest version of mup npm update mup -g .

  • The first step is to remove any previously existing application package and nodejs. Mup installs the application in /opt/ , and there you can find your_app and nodejs . Remove them.

  • Make sure you have the correct version of node, 0.10.36 is only 1 and the following parameters in the mup.json file:

     { ... "setupMongo": true, "setupNode": true, "nodeVersion" : "0.10.36", "setupPhantom": true, "enableUploadProgressBar": true, // Application name (No spaces) "appName": "your_app", // Location of app (local directory) "app": ".", ... } 
  • Run:

     $ mup setup $ mup deploy 
  • Go to the server folder on your server and rebuild the modules:

     $ cd /opt/your_app/app/programs/server $ npm rebuild $ npm install 

    Optional: $ sudo npm update node-gyp -g

  • Finally, restart the application, mogodb and any web server processes such as nginx 6 . After completing the above steps, you may want to look at the security steps below for additional debugging options.



Security steps

There are several other steps you can follow:

  • Note that apache can also bind to the same port that nginx runs on. View application error logs and web server error logs to see if there are any problems. Stop apache with sudo service apache2 stop or copy forced closure (not recommended) of any running processes on port 80.

    • Then delete or move the conf apache2 file so that it does not start again. All conf files are located in /etc/init or /etc/init.d .
  • Use $ mup logs -f to view $ mup logs -f . To view errors from your application, the end of the /var/log/upstart/your_app.log file is useful (provided that you configure the upstart).

  • If you are using nginx, make sure your directories are symbolically linked.

     $ ln -s /etc/nginx/sites-available/your_server_config /etc/nginx/sites-enabled/your_server_config 

    Also, make sure you specify default_server 5 in your_server_config .

  • Make sure mongodb can work.



References

  • Meteor version 1.0.4.1 (released at the end of March 2015) requires the installation of node version 0.10.36. I recommend using node n version manager to control the version of node on your server at any given time. Link

  • Terrible error [XXX.XX.XXX.XX] Error: '/opt/your_app/programs/server/node_modules/fibers/bin/linux-x64-v8-3.28/fibers.node' is missing. Try reinstalling 'node-fibers'? [XXX.XX.XXX.XX] Error: '/opt/your_app/programs/server/node_modules/fibers/bin/linux-x64-v8-3.28/fibers.node' is missing. Try reinstalling 'node-fibers'? . Link

  • The procedure changes here: Link .

  • For your information, I used DigitalOcean a very useful guide for deploying a meteorite application on a server. Link

  • Specifying default_server . Link

  • Common processes for restarting: sudo service mongod/nginx/yourapp restart .

+5
source

I had the same problem and did the following:

  • Remove nodejs

    sudo apt-get remove nodejs

  • Delete all remaining files

    rm -rf ~/.nvm ~/.npm

    sudo rm -rf /usr/bin/node /opt/nodejs /usr/lib/node_modules /usr/local/lib/node_modules

  • Update default node version by default in mup.json file

    "nodeVersion": "0.10.33",

  • Run setup and deployment of mup

    mup setup

    mup deploy

-1
source

Source: https://habr.com/ru/post/981109/


All Articles