ForceUniverse / dart-force

Dart Realtime Web Framework!
https://pub.dartlang.org/packages/force
Other
89 stars 9 forks source link

Cant Start Force With GAE #27

Closed cgarciae closed 9 years ago

cgarciae commented 9 years ago

I have this minimal code and I keep getting

INFO: default: "GET /_ah/health?IsLastSuccessful=no HTTP/1.1" 503 -
WARNING: All instances may not have restarted

when I try to start the local server. Here is the code

server.dart

library force_angular;

import 'package:force/force_serverside.dart';
import 'package:forcemvc/force_mvc.dart';
import 'package:mustache4dart/mustache4dart.dart';
import 'package:appengine/appengine.dart';

main() {

    // Create a force server
    ForceServer fs = new ForceServer();

    runAppEngine(forceServer.requestHandler).then((_) {

        // Setup logger
        fs.setupConsoleLog();

        // we need to change {{ into [[ because of angular
        if (fs.server.viewRender is MustacheRender) {
            MustacheRender mustacheRender = fs.server.viewRender;
            mustacheRender.delimiter = new Delimiter('[[', ']]');
        }

        // Tell Force what the start page is!
        fs.server.use("/", (req, model) => "angularforce");

    });
}

angularforce.html

<!DOCTYPE html>
    <html ng-app>
    <head>
        <title>Hello World GAE</title>
    </head>
    <body>

        <h1>Hello HTML</h1>

        <script type="applicataion/dart" src="angularforce.dart"></script>
        <script type="text/javascript" src="packages/browser/dart.js"></script>
    </body>
</html>

angularforce.dart

import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';

void main() {
  applicationFactory()
      .run();
}
jorishermans commented 9 years ago

Strange, how can we get more info from GAE :s

INFO: default: "GET /_ah/health?IsLastSuccessful=no HTTP/1.1" 503 - WARNING: All instances may not have restarted

Looks like he has problems with restarting himself, I had this issue too.

jorishermans commented 9 years ago

Can you stop your gcloud process and try again?

cgarciae commented 9 years ago

I am running it locally through gcloud preview app run app.yaml.

jorishermans commented 9 years ago

console

It seems like it works here ...

jorishermans commented 9 years ago

You need to do pub build also ... but you can also define DART_PUB_SERVE environment in your docker instance.

I am afraid your issue is something GAE related that you encounter ... can you verify this? I will try to work on a version of GAE that works on my machine and put this online ;)

Hopefully this helps you a bit forward!

jorishermans commented 9 years ago

I get message Info: Instances restarted

and not:

WARNING: All instances may not have restarted

try to update your gcloud components like follow:

gcloud components update app

cgarciae commented 9 years ago

Updated gcloud and nothing. Are you running the same scripts as me? Maybe there is something wrong with my server.dart. When I use this "Hello World" code from the GAE tutorial

import 'dart:io';

import 'package:appengine/appengine.dart';

main() {
    runAppEngine((HttpRequest request) {
        request.response
            ..write('Hello, world!')
            ..close();
    });
}

it works perfectly.

jorishermans commented 9 years ago

I did some test, it has something todo with websockets, when the client tries to establish a websocket connection he fails! So how can we fixed that? Do you know where we can find more logging from appengine? So we can see stacktraces, and info messages from the logging?

Just try to comment ForceClient, if that also works on your side then we are on the same line ;-)

Then we need to figure out why the websockets are not working, it would be great if you could help me out on that one!

cgarciae commented 9 years ago

I saw a post about websockets on AppEngine, it seems you have to configure GAE/Docker to open some ports and channel the connection through those. Will try to find the post.

jorishermans commented 9 years ago

I uploaded a appengine example: https://github.com/jorishermans/appengine-force-example

It uses long polling for the moment until we figured out how to use, enable websockets on appengine!

cgarciae commented 9 years ago

Your code was really useful. It turns out I had a bug on my code. It working fine now and tested on a real URL on App Engine.

scne commented 9 years ago

I've same problem :s

jorishermans commented 9 years ago

Is it a dart force or a forcemvc problem? I know that you need to configure app engine to work with websockets, I need to dive into it too see how you can do that. A normal forcemvc project should work.

Look at my uploaded example https://github.com/jorishermans/appengine-force-example

jorishermans commented 9 years ago

This is how you can debug on google app engine, getting more info and maybe stacktrace info about what is going wrong.

http://stackoverflow.com/questions/26807828/how-can-i-debug-a-dart-appengine-app

This can help me to guide you!

scne commented 9 years ago

This is my code https://github.com/scne/dartrest Maybe there is something wrong?

jorishermans commented 9 years ago

remove:

// Start serving force with a randomPortFallback webApp.start(fallback: randomPortFallback);

in server.dart and try again

The appengine runtime starts your app, so starting it with ForceMVC is not needed.

if this doesn't help let me know and I will debug it later today.

scne commented 9 years ago

Nothing! This is screenshot of shell. I follow this guide https://www.dartlang.org/cloud/setup.html screenshot from 2014-12-02 16 38 49 screenshot from 2014-12-02 16 39 16

jorishermans commented 9 years ago

Can you run this command.

gcloud --verbosity debug preview app run app.yaml

Will it give you more debug info? If so please put that info here.

Also killing your docker proccess and starting it again can help.

scne commented 9 years ago

INFO: Creating container... INFO: Container e40102016036bcc2bc36a3b4f5a39c2c427a107e8ead3f86d025cdce950e25af created. DEBUG: Container: e40102016036: Observatory listening on http://0.0.0.0:8181 DEBUG: Container: e40102016036: 'package:forcemvc/server/serving_files.dart': error: line 46 pos 71: use flag --enable-async to enable async/await features Future serveFile(HttpRequest request, String root, String fileName) async { ^ DEBUG: Automatic cleanup... DEBUG: Cleanup finished. INFO: default: "GET /_ah/health?IsLastSuccessful=no HTTP/1.1" 503 - DEBUG: Health check response [''] and status 503 Service Unavailable for instance 0. DEBUG: Health check state for instance: 0: 3 consecutive UNHEALTHY responses. DEBUG: Performing health check for instance 0.

jorishermans commented 9 years ago

Ow I see you are using my github version that is using await, great, try to start it with this command.

gcloud --verbosity --enable-async debug preview app run app.yaml

scne commented 9 years ago

ERROR: (gcloud) argument --verbosity: expected one argument Maybe after --verbosity I have to use debug preview ...

jorishermans commented 9 years ago

It is a dartvm parameter that you need to add, don't know how to do that, maybe within app.yaml file.

Otherwise just use latest version from within pub and don't point to my github repo.

forcemvc: ">=0.5.10 <0.6.0"

5.10 doesn't use the await/async syntax, going to search how we can use this in app engine.

scne commented 9 years ago

With version 0.5.10 is ok!