Deploy app to remote server via ssh
Last updated 5 years ago by lestad .
Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install deplosha 
SYNC missed versions from official npm registry.

Stories in Ready Build Status Package version


Deplosha is a fork of Roco

Command line tool allows you to execute commands on remote server(s) or locally. Useful for deployment, monitoring and other tasks.


npm install deplosha -g


deplosha deploy:setup   # prepare deploy (create directories)
deplosha deploy         # update code and restart server


Use one of three ways for configuring your app: package.json, or ENV vars


deplosha looking for package.json in working directory and set these variables:

  • as application
  • as repository
  • pkg.repository.type as scm

deplosha looking for file in /etc/, ~/, ./, ./config/ paths

This files can extend behavior of deplosha and configure variables. Checkout examples to learn how to use it


my ~/ file

set 'hosts', ['', '']
set 'branch', 'release/latest'

envKit 'staging', ->
    set 'hosts', ['']
    set 'branch', 'release/staging'

namespace 'deploy', ->
    # show status of running application
    task 'status', ->
        run "sudo status #{deplosha.application}"

namespace 'git', ->
    # setup remote private repo
    task 'remote', ->
        app = deplosha.application
        run """
        mkdir #{app}.git;
        cd #{app}.git;
        git --bare init;
        """, (res) ->
            localRun """
            git remote add origin #{res[0].host}:#{app}.git;
            git push -u origin master

# some tasks for monitoring server state
namespace 'i', ->
    task 'disk', (done) -> run 'df -h', done
    task 'top',  (done) -> run 'top -b -n 1 | head -n 12', done
    task 'who',  (done) -> run 'who', done
    task 'node', (done) -> run 'ps -eo args | grep node | grep -v grep', done
    task 'free', (done) -> run 'free', done

    task 'all', (done) ->
        sequence 'top', 'free', 'disk', 'node', done

    # display last 100 lines of application log
    task 'log', ->
        run "tail -n 100 #{deplosha.sharedPath}/log/#{deplosha.env}.log"


Current deploy script allows you deploy upstart-controlled applications out of box, just run

deplosha deploy:setup:upstart

to setup upstart script and create dirs, if you use another solution for node daemon management feel free to rewrite start/stop/restart scripts:

namespace 'deploy', ->
    task 'start', (done) -> run "cd #{deplosha.currentPath}; forever start server.js"
    task 'stop', (done) -> run "cd #{deplosha.currentPath}; forever stop"

Environment Kit


deplosha staging deploy

staging is custom environment. You can change default values with envKit

set 'hosts', ['']

envKit 'staging', ->
    set 'hosts', ['']

envKit 'development', ->
    set 'hosts', ['']
    set 'env', 'production' # override environment

If you change environment, host too changes

Another snippets

Update nodejs on server(s)


set 'nodever', '0.8.10'
namespace 'node', ->
  task 'update', (done) -> sequence 'download', 'unpack', 'compile', 'install', done
  task 'rebuild', (done) -> sequence 'unpack', 'compile', 'install', done
  task 'download', (done) ->
    run "cd /tmp && wget{deplosha.nodever}/node-v#{deplosha.nodever}.tar.gz", done
  task 'unpack', (done) ->
    run "cd /tmp && tar xfv node-v#{deplosha.nodever}.tar.gz", done
  task 'compile', (done) ->
    run "cd /tmp/node-v#{deplosha.nodever} && ./configure && make", done
  task 'install', (done) ->
    run "cd /tmp/node-v#{deplosha.nodever} && sudo make install", done

Example: update nodejs on localhost and hosts

HOSTS=localhost, deplosha node:update



Current Tags

  • 0.7.0                                ...           latest (5 years ago)

7 Versions

  • 0.7.0                                ...           5 years ago
  • 0.1.1-dev3                                ...           5 years ago
  • 0.1.1-dev1                                ...           5 years ago
  • 0.1.0-free2                                ...           5 years ago
  • 0.1.0-free1                                ...           5 years ago
  • 0.1.0-free                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © |