redstone-dart / redstone

A metadata driven microframework for Dart.
http://redstone-dart.github.io/redstone
MIT License
342 stars 42 forks source link

Improve documentation: Redstone with GAE #49

Open cgarciae opened 9 years ago

cgarciae commented 9 years ago

Can you use Redstone in Google App Engine? If so, can you give me a "Hello World" example to start using it?

luizmineo commented 9 years ago

To be honest, I didn't have the time yet to play with appengine, but in theory, you can easily use Redstone with it. The trick is that you can't call the start() function directly to start the server. Instead, you have to call setup() to install the handlers, and then call handleRequest() for every request received. Example:

import 'dart:io';
import 'package:appengine/appengine.dart';
import 'package:redstone/server.dart' as app;

@app.Route("/")
helloWorld() => "Hello, World!";

main() {
  app.setupConsoleLog();
  app.setup();
  runAppEngine((req) => app.handleRequest(req));
}

I will update this issue when I test it better, but let me know if this example works for you.

cgarciae commented 9 years ago

Do you have to do anything special when deploying?

cgarciae commented 9 years ago

@luizmineo app.setup doesn't exist, did you mean app.start or app.setUp?

BTW: it easier to simply call runAppEngine (app.handleRequest)

luizmineo commented 9 years ago

My bad, it's app.setUp(). You need to call this function, or your handlers won't be installed. Also, I don't think you need to do anything special on deploy.

cgarciae commented 9 years ago

@luizmineo I was following the Wiki and it says to deploy/build with ginder. I got an error trying to use grinder but the method above worked, so when do you have to use it?

luizmineo commented 9 years ago

grinder is useful when you deploy your app to your own server. Services like heroku, appengine and dartvoid usually handles the build and deploy process for you, so you don't need a build script

digizen commented 9 years ago

I also got an error using Grinder. After some debugging, I found that the error it throws is because it's trying to execute "pub" which it can't find. Any ideas?

luizmineo commented 9 years ago

@digizen try to set the `DART_SDK environment variable and see if that helps

digizen commented 9 years ago

No dice, the DART_SDK variable was already set to my Dart install folder. It's almost like the "pub" command isn't on the path, but this is also false - I can execute "pub" from the command line. I wonder where Grinder searches for files to execute, and if there's any way to tell it the location of "pub"?