Permalink
Browse files

Different job names for production and other envs

  • Loading branch information...
1 parent a1f21b1 commit e413b66035a4b1af25a0c1b6af309a94faa52907 @1602 committed Feb 9, 2012
Showing with 34 additions and 8 deletions.
  1. +5 −1 README.md
  2. +15 −4 cockout/deploy.coffee
  3. +13 −2 lib/rockout.js
  4. +1 −1 package.json
View
6 README.md
@@ -70,6 +70,10 @@ namespace 'i', ->
task 'all', (done) ->
sequence 'top', 'free', 'disk', 'node', done
+
+ # display last 100 lines of application log
+ task 'log', ->
+ run "tail -n 100 #{roco.sharedPath}/log/#{roco.env}.log"
```
## Deploy
@@ -89,4 +93,4 @@ namespace 'deploy', ->
## License
-MIT
+MIT
View
19 cockout/deploy.coffee
@@ -24,6 +24,11 @@ ensure 'latestReleasePath', -> path.resolve(roco.releasesPath, ''+roco.latestRel
ensure 'env', 'production'
ensure 'nodeEntry', 'server.js'
ensure 'appPort', 3001
+ensure 'job', ->
+ if roco.env == 'production'
+ roco.application
+ else
+ roco.application '-' + roco.env
namespace 'deploy', ->
@@ -79,13 +84,13 @@ namespace 'deploy', ->
""", done
task 'restart', (done) ->
- run "sudo restart #{roco.application} || sudo start #{roco.application}", done
+ run "sudo restart #{roco.job} || sudo start #{roco.job}", done
task 'start', (done) ->
- run "sudo start #{roco.application}", done
+ run "sudo start #{roco.job}", done
task 'stop', (done) ->
- run "sudo stop #{roco.application}", done
+ run "sudo stop #{roco.job}", done
task 'rollback', (done) ->
sequence 'prepare', 'rollback:code', 'restart', 'rollback:cleanup', done
@@ -133,5 +138,11 @@ namespace 'deploy', ->
end script
respawn
"""
- run "sudo echo '#{ups}' > /tmp/upstart.tmp && sudo mv /tmp/upstart.tmp /etc/init/#{roco.application}.conf", done
+
+ if roco.env == 'production'
+ file = roco.application
+ else
+ file = "#{roco.application}-#{roco.env}"
+
+ run "sudo echo '#{ups}' > /tmp/upstart.tmp && sudo mv /tmp/upstart.tmp /etc/init/#{file}.conf", done
View
15 lib/rockout.js
@@ -11,13 +11,24 @@ exports.init = function () {
};
exports.perform = function (what) {
- var cmd = what[0];
+ var env = what[0];
+ var cmd = what[1];
+
+ // check whether env param omitted
+ if (roco[env] || roco[env + ':default']) {
+ cmd = env;
+ env = 'production';
+ }
+
+ console.log('Running in', env, 'mode');
+ roco.set('env', env);
+
if (roco[cmd]) {
roco[cmd]();
} else if (roco[cmd + ':default']) {
roco[cmd + ':default']();
} else {
- roco.abort('Unknown commad', cmd);
+ roco.abort('Unknown command ' + cmd);
}
};
View
2 package.json
@@ -2,7 +2,7 @@
"author": "Anatoliy Chakkaev <rpm1602 at gmail dot com>",
"name": "roco",
"description": "Deploy app to remote server via ssh",
- "version": "0.0.1",
+ "version": "0.0.2",
"repository": {
"type": "git",
"url": "git@github.com:1602/roco.git"

0 comments on commit e413b66

Please sign in to comment.