Skip to content
Browse files

[api] Update to jitsu config. Add start/stop commands and API methods

  • Loading branch information...
1 parent d20f3bc commit 3401eb7fbf7278665835fa818f35faba8509ef3e @indexzero indexzero committed Mar 8, 2011
Showing with 47 additions and 4 deletions.
  1. +3 −3 lib/jitsu/api/apps.js
  2. +32 −0 lib/jitsu/commands/apps.js
  3. +12 −1 lib/jitsu/config.js
View
6 lib/jitsu/api/apps.js
@@ -90,7 +90,7 @@ Apps.prototype.destroy = function (name, callback) {
// Starts the application with `name` for the authenticated user.
//
Apps.prototype.start = function (name, callback) {
- this._request('POST', ['apps', jitsu.config.username, name, 'start'], { start: name }, callback, function (res, result) {
+ this._request('POST', ['apps', jitsu.config.username, name, 'start'], callback, function (res, result) {
callback();
});
};
@@ -102,7 +102,7 @@ Apps.prototype.start = function (name, callback) {
// Starts the application with `name` for the authenticated user.
//
Apps.prototype.restart = function (name, callback) {
- this._request('POST', ['apps', jitsu.config.username, name, 'restart'], { restart: name }, callback, function (res, result) {
+ this._request('POST', ['apps', jitsu.config.username, name, 'restart'], callback, function (res, result) {
callback();
});
};
@@ -114,7 +114,7 @@ Apps.prototype.restart = function (name, callback) {
// Stops the application with `name` for the authenticated user.
//
Apps.prototype.stop = function (name, callback) {
- this._request('POST', ['apps', jitsu.config.username, name, 'stop'], { stop: name }, callback, function (res, result) {
+ this._request('POST', ['apps', jitsu.config.username, name, 'stop'], callback, function (res, result) {
callback();
});
};
View
32 lib/jitsu/commands/apps.js
@@ -184,7 +184,23 @@ apps.destroy = function (name, callback) {
// this will start the application in the current directory.
//
apps.start = function (name, callback) {
+ if (!callback) {
+ callback = name;
+ return jitsu.utils.readPackage(process.cwd(), function (err, package) {
+ name = package.name;
+ executeStart();
+ });
+ }
+
+ function executeStart () {
+ winston.info('Starting app ' + name.magenta);
+ jitsu.apps.start(name, function (err) {
+ winston.info('App ' + name.magenta + ' is now started');
+ return err ? callback(err) : callback();
+ });
+ }
+ executeStart();
};
//
@@ -195,5 +211,21 @@ apps.start = function (name, callback) {
// this will stop the application in the current directory.
//
apps.stop = function (name, callback) {
+ if (!callback) {
+ callback = name;
+ return jitsu.utils.readPackage(process.cwd(), function (err, package) {
+ name = package.name;
+ executeStop();
+ });
+ }
+
+ function executeStop () {
+ winston.info('Stopping app ' + name.magenta);
+ jitsu.apps.stop(name, function (err) {
+ winston.info('App ' + name.magenta + ' is now stopped');
+ return err ? callback(err) : callback();
+ });
+ }
+ executeStart();
};
View
13 lib/jitsu/config.js
@@ -11,14 +11,25 @@ var path = require('path'),
var config = exports, settings = config.settings = {
root: process.env.HOME,
- remoteUri: 'http://localhost',
+ protocol: 'http',
+ remoteHost: 'localhost',
userconfig: '.jitsuconf',
tmproot: '/tmp',
tar: 'tar',
gzipbin: 'gzip'
};
//
+// Define the `remoteUri` property for the settings object
+//
+Object.defineProperty(config.settings, 'remoteUri', {
+ get: function () {
+ var port = this.port ? ':' + this.port : ''
+ return [this.protocol, '://', this.remoteHost, port].join('');
+ }
+});
+
+//
// ### @log {Object}
// Log level configuration for jitsu.
//

0 comments on commit 3401eb7

Please sign in to comment.
Something went wrong with that request. Please try again.