Make start/stop just a installation code
the runState now just tracks if an app is stopped.
This commit is contained in:
17
src/apps.js
17
src/apps.js
@@ -64,7 +64,7 @@ exports = module.exports = {
|
||||
PORT_TYPE_TCP: 'tcp',
|
||||
PORT_TYPE_UDP: 'udp',
|
||||
|
||||
// installation codes (keep in sync in UI)
|
||||
// task codes - the installation state is now a misnomer (keep in sync in UI)
|
||||
ISTATE_PENDING_INSTALL: 'pending_install', // installs and fresh reinstalls
|
||||
ISTATE_PENDING_CLONE: 'pending_clone', // clone
|
||||
ISTATE_PENDING_CONFIGURE: 'pending_configure', // infra update
|
||||
@@ -78,13 +78,13 @@ exports = module.exports = {
|
||||
ISTATE_PENDING_RESTORE: 'pending_restore', // restore to previous backup or on upgrade
|
||||
ISTATE_PENDING_UPDATE: 'pending_update', // update from installed state preserving data
|
||||
ISTATE_PENDING_BACKUP: 'pending_backup', // backup the app. this is state because it blocks other operations
|
||||
ISTATE_PENDING_START: 'pending_start',
|
||||
ISTATE_PENDING_STOP: 'pending_stop',
|
||||
ISTATE_ERROR: 'error', // error executing last pending_* command
|
||||
ISTATE_INSTALLED: 'installed', // app is installed
|
||||
|
||||
// run states
|
||||
RSTATE_RUNNING: 'running',
|
||||
RSTATE_PENDING_START: 'pending_start',
|
||||
RSTATE_PENDING_STOP: 'pending_stop',
|
||||
RSTATE_STOPPED: 'stopped', // app stopped by us
|
||||
|
||||
// health states (keep in sync in UI)
|
||||
@@ -789,7 +789,8 @@ function install(data, user, auditSource, callback) {
|
||||
alternateDomains: alternateDomains,
|
||||
env: env,
|
||||
label: label,
|
||||
tags: tags
|
||||
tags: tags,
|
||||
runState: exports.RSTATE_RUNNING
|
||||
};
|
||||
|
||||
appdb.add(appId, appStoreId, manifest, location, domain, translatePortBindings(portBindings, manifest), data, function (error) {
|
||||
@@ -1564,10 +1565,10 @@ function start(appId, callback) {
|
||||
get(appId, function (error, app) {
|
||||
if (error) return callback(error);
|
||||
|
||||
error = checkAppState(app, exports.exports.ISTATE_INSTALLED); // FIXME
|
||||
error = checkAppState(app, exports.ISTATE_PENDING_START);
|
||||
if (error) return callback(error);
|
||||
|
||||
scheduleTask(appId, { /* args */ }, { runState: exports.RSTATE_PENDING_START }, callback);
|
||||
scheduleTask(appId, { /* args */ }, { installationState: exports.ISTATE_PENDING_START, runState: exports.RSTATE_RUNNING }, callback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1580,10 +1581,10 @@ function stop(appId, callback) {
|
||||
get(appId, function (error, app) {
|
||||
if (error) return callback(error);
|
||||
|
||||
error = checkAppState(app, exports.ISTATE_INSTALLED); // FIXME
|
||||
error = checkAppState(app, exports.ISTATE_PENDING_STOP);
|
||||
if (error) return callback(error);
|
||||
|
||||
scheduleTask(appId, { /* args */ }, { runState: exports.RSTATE_PENDING_STOP }, callback);
|
||||
scheduleTask(appId, { /* args */ }, { installationState: exports.ISTATE_PENDING_STOP, runState: exports.RSTATE_STOPPED }, callback);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user