pegli / couchbase_ti

CouchBase Mobile module for Appcelerator Titanium
51 stars 7 forks source link

On Resume from Pause the local server appears to have stopped working. #7

Open Galaloo opened 12 years ago

Galaloo commented 12 years ago

CouchBooks is running on a iPhone 4, iOS 5. I haven't been able to replicate this on the simulator because of how the process is handled. The module was downloaded from Appcelerator Marketplace.

Summary: When CouchBooks is put in to the background (paused) and the device is turned off. The local server is shutdown by the iOS. On Resume I have not been able to restart the server.

Titanium.App.addEventListener('resume', function(e) {
Ti.API.info('back from pause');
  db.info(function(resp, status) {
    if(status === 200) {
        //the local couch server is still running
        //do something like _replicate
    } else {
        //the local couch server is not running, do a restart
        var couchbase_ti = require('com.obscure.couchbase_ti');
        couchbase_ti.addEventListener("com.obscure.couchbase_ti.server_started", function(e) {
            localServer = e.serverUrl;
            controller.open(books.createRootWindow(controller, db));
        });
        couchbase_ti.startCouchbase();
    }
  });
});

How do I restart the server on Resume?

Other than not being able to restart the server after Power Off/ Resume, CouchBooks has been working great. I even have _replicate running with a remote CouchDB instance running on an Amazon EC2 server. The speed is impressive.

Update: This thread refers to the resume from background problem and resolution in Couchbase Mobile back in August. https://groups.google.com/group/mobile-couchbase/browse_thread/thread/ed4f90d98e0fd343/aab8d05b4187fa95?lnk=gst&q=background#aab8d05b4187fa95

Galaloo commented 12 years ago

Nothing huh? I opted to Stop the app when it is put into the background. The server is restarted when the app restarts. Bleh.