Skip to content

Instantly share code, notes, and snippets.

@msurguy
Forked from Termina1/gist:3928508
Created November 2, 2012 19:12
Show Gist options
  • Save msurguy/4003696 to your computer and use it in GitHub Desktop.
Save msurguy/4003696 to your computer and use it in GitHub Desktop.
meteor deploy cake task
exec = require('child_process').exec
ssh = require 'NodeSSH'
scp = require 'scp'
deploy = (host, name, pass, path, start = true, port=3001) ->
client = new ssh host, name, pass
console.log 'connecting to server'
client.connect ->
client.once 'data', ->
console.log 'cleaning old code'
client.write "cd #{path}\r\n"
client.write 'rm -rf bundle\r\n'
console.log "creating bundle for deploy"
exec 'meteor bundle myapp.tgz', {}, ->
console.log "bundle created, uploading to server"
scp.send file: 'myapp.tgz', user: name, password: pass, host: host, path: path, ->
client.write 'tar -xzf myapp.tgz\r\n'
console.log 'unpacking files'
client.write 'rm myapp.tgz\r\n'
client.write 'cd bundle/server\r\n'
client.write 'rm -rf node_modules/fibers\r\n'
client.write 'npm install fibers\r\n'
client.write "cd #{path}\r\n"
if start
client.write 'forever stopall'
client.write "PORT=#{port} MONGO_URL=mongodb://localhost forever start #{path}/bundle/main.js\r\n"
client.write 'exit\r\n'
task 'deploy', ->
deploy 'ваш хост', 'имя пользователя', 'пароль', 'путь до папки на сервере', 'перезапускать или нет сервер', 'порт'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment