Closed movabo closed 8 years ago
This has actually been discussed by me and @aschaeffer beforehand. The main problem is that there's no-yet asynchronous architecture behind the application server, as neither the plugin system is implemented ..
095e275 introduces a ready
event and an asynchronous startup routine.
How about you be the first to write a plugin for an onReady
state URL?
This will be fixed in master by completing #354 and #368.
Now it's possible to watch if an instance is running:
let instanceId = 31416;
let root = ...;
let instanceNode = root.instances.getChild(instanceId);
instanceNode.state.on('postSet', function(oldValue, newValue) {
switch (newValue) {
case 'stopped':
if (oldValue == null) {
log.info('Instance has been created');
} else if (oldValue == 'started' || oldValue == 'running') {
log.info('Instance has been stopped');
}
break;
case 'started':
log.info('Instance has been started, but there is no RPC connection established right now');
break;
case 'running':
if (oldValue == 'started') {
log.info('Instance has been connected and is now running');
} else if (oldValue == 'paused') {
log.info('Instance has been resumed and is now running again');
}
break;
case 'paused':
log.info('Instance is paused');
break;
}
});
Right now when you edit for example code/node/app/server.js and add these two lines:
one will log the right amout of maxfps and the other won't. I guess this is due to the fact that the initialisation did not finish.
So a callback should be added, which will be executed after the initialistation finished.
For example: