diff options
author | Aleksey Lim <alsroot@sugarlabs.org> | 2012-07-23 13:01:40 (GMT) |
---|---|---|
committer | Aleksey Lim <alsroot@sugarlabs.org> | 2012-07-23 13:01:40 (GMT) |
commit | 5f36e41cfbe7679ed273a027b01fa7d3cbf97ee3 (patch) | |
tree | 06784d5d8134cf4633a0b3e81c71ffb1bad43844 /sugar-network-service | |
parent | ad4375ad5cc80b8cc4ac356d81098df0408653f6 (diff) |
Ensure that checked-in activities exist on startup
Diffstat (limited to 'sugar-network-service')
-rwxr-xr-x | sugar-network-service | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/sugar-network-service b/sugar-network-service index 34abaf5..48672f5 100755 --- a/sugar-network-service +++ b/sugar-network-service @@ -109,7 +109,8 @@ class Application(application.Application): volume = Volume(self._db_path) try: volume.populate() - activities.populate(volume, local.activity_dirs.value, root) + activities.populate(volume['context'], local.activity_dirs.value, + root) directory = volume['context'] while self.args: @@ -143,7 +144,7 @@ class Application(application.Application): @application.command( 'start service and log to files', name='start', keep_stdout=True) - def _start(self, local_run=False): + def _start(self): # In case if it is new Sugar Shell profile crypto.ensure_dsa_pubkey(sugar.profile_path('owner.key')) @@ -154,17 +155,26 @@ class Application(application.Application): mountset['~'] = HomeMount(volume) mountset['/'] = RemoteMount(volume) - if local_run or webui.webui.value: - # Point clients to `mountset` directly passing over IPC - Client.connection = mountset + # Point this process code to `mountset` directly passing over IPC + Client.connection = mountset def delayed_start(event=None): logging.info('Proceed delayed start') mountset.disconnect(delayed_start) - jobs.spawn(activities.monitor, volume, local.activity_dirs.value) - jobs.spawn(volume.populate) - jobs.spawn(datastore.populate, volume['artifact']) + volume.populate() + datastore.populate(volume['artifact']) + + stale_keep_impls = [] + Context = Client('~').Context + for context in Context.cursor(keep_impl=[1, 2]): + if not activities.ensure_checkins(context.guid): + stale_keep_impls.append(context.guid) + for guid in stale_keep_impls: + Context(guid, keep_impl=0).post() + + jobs.spawn(activities.monitor, volume['context'], + local.activity_dirs.value) if webui.webui.value: host = (webui.webui_host.value, webui.webui_port.value) @@ -216,7 +226,7 @@ class Application(application.Application): if not self.check_for_instance(): printf.info('%s is not started, ' \ 'launch it for this command only', self.name) - server = coroutine.spawn(self._start, True) + server = coroutine.spawn(self._start) coroutine.dispatch() Client.connection.opened.wait() |