Pergunta

Let me start by saying I'm absolutely confused. Now that that's out of the way, here's what I've done:

I have two remote servers (Ubuntu) ( Development & Production ) and my local machine.

On Local Machine:

  1. I created a basic meteor app - Hello, world.
  2. Initiated a git repository
  3. Created a dev branch
  4. Pushed to beanstalkapp(like github) where I've created an automatic deploy anytime dev branch is updated.

On Dev Machine - Remote dev.mysite.com

  1. Files received from previous mentioned steps
  2. I can treat the app like it's on my localhost computer by running $ meteor in which it creates a MongoDB instance and starts listening on 3000

Ok let me stop there and explain my desirable work-flow which I'm happy to change if there's a better way. I need my dev site online, but I don't want it hosted on meteor.com

  1. I don't understand what I'm reading about having to "deploy" my app. I guess this is what minimizes everything?
  2. How can I benefit from a git work-flow to auto deploy changes to the server of my choice without having to go through this deploy each time?
  3. I just signed up for MongoHQ and have a database setup that I'd like to use other than Meteor's defaulting to creating a local instance. Can I change this to point to the MongoHQ remote database through my local computer, push the changes to the repo and them deploy to my dev site? Do I have to do this on the dev machine?
  4. What do I have to do to get it listening on port 80? Or does it listen for any open port automatically?

I hope my questions give you insight to my dilemma, in which I just don't understand the work-flow and the docs are confusing. I just want to be able to work on my site/app on my local computer, commit and push my changes which are deployed to the development server automatically for me... but this deploy deal is throwing me off, and the database is throwing me off.

Is there a better way to create a fast and productive workflow from local to dev to production? I didn't mention production above because I was planning on using the same auto deploy. I would merge my dev branch with master and push master which would auto deploy to the production server. I'd have a separate database for production, so this has me in a pickle as well... if I'm merging, I'm crossing database configurations, or is this strictly done on the server one time and I don't have to worry about it?

Gah. Please help! Thank you.

Foi útil?

Solução

Short of posting a few long gists that configure your servers, I can steer you in the right direction:

1 & 2 & 3. The pattern is to set up a post-receive hook on each machine. The hook should:

  • clone the repo to a tmp directory
  • call meteor bundle (produces a .tar.gz file)
  • stop your running meteor application
  • Extract bundle to a known application directory
  • start your meteor application

You can set up a script in init.d which uses forever to operate meteor, eg. /etc/init.d/meteor start|stop

You can also add your required configuration variables - eg MONGO_URL

example of starting meteor:

      echo "$(date +'%Y-%m-%d %T,000') INFO $SERVICE_NAME started" >> $LOG_DIR/forever.log
      export MONGO_URL=''
      export PORT=3000
      export ROOT_URL=myserver.myapp.com
      export METEOR_SETTINGS="\`cat /path/to/production/settings.json\`"
      export MAIL_URL=mail.myapp.com

      sudo -u meteor -H -E forever -l $LOG_DIR/forever.log -o $LOG_DIR/out.log -e $LOG_DIR/err.log --minUptime 30000 --spinSleepTime 5000 -a -s start $WWW_APP_DIR/main.js
      ;;

4 . unless you run meteor as root, no luck with port 80 - you're better off having nginx sit infront of Meteor and serve up static resources anyway - so get an nginx config, eg.

server {                                                                                                                     
  listen 3000;                                                                                                               

  server_name localhost;                                                                                                     

  # this should include any files / directories that belong to /public
  location ~ "^/(resources/|robots.txt|humans.txt|favicon.ico)" {
    root /path/to/bundle/programs/client/app/;
    access_log off;
    expires max;
  }

  # this is any assets that belong in packages
  location ~ "^/packages" {
    root /path/to/bundle/programs/client/;
    access_log off;
    expires max;
  }

  # this is for the main css & js
  location ~* "^/[a-z0-9]{40}\.(css|js)$" {
    root /path/to/bundle/programs/client;
    access_log off;
    expires max;
  }

  # this is for any sockets
  location /sockjs/ {
    proxy_pass http://meteor;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
  }

  location / {
    proxy_pass http://meteor;
    # dont know if this is missing some stuff
  }
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top