A bunch of changes that make it easy to run the gf server with lighttpd

This commit is contained in:
bjorn
2008-10-16 13:39:09 +00:00
parent f211fc10ca
commit 44eeb7a0f7
8 changed files with 131 additions and 15 deletions

View File

@@ -1,11 +1,11 @@
GFCFLAGS = +RTS -K100M -RTS --cpu
.PHONY: gf.fcgi food demo
.PHONY: pgf.fcgi food demo
gf.fcgi:
pgf.fcgi:
cabal configure
cabal build
cp dist/build/gf.fcgi/gf.fcgi .
cp dist/build/pgf.fcgi/pgf.fcgi .
gwt:
gwt-client/Translate-compile
@@ -34,7 +34,7 @@ lang.pgf: LangBul-noparse.pgf LangCat-noparse.pgf LangDan-parse.pgf LangEng-pars
test.pgf: LangEng-parse.pgf LangGer-parse.pgf
gfc $(GFCFLAGS) --name=test $^
gwt-installball: gf.fcgi gwt
gwt-installball: pgf.fcgi gwt
rm -rf tmp/gwt-client
rm -f gf-server-installball.tar.gz
mkdir -p tmp/gwt-client

View File

@@ -24,7 +24,25 @@ $ make
$ make food
== Running ==
== Running (lighttpd) ==
- Install lighttpd
- MacPorts:
$ sudo port install lighttpd
- Run lighttpd:
$ lighttpd -f lighttpd.conf -D
- First test from the command-line, since debugging is harder from the AJAX UI:
$ curl 'http://localhost:41296/gf/translate?input=this+fish&cat=Item&from=FoodEng'
- Go to http://localhost:41296/simple-client.html in your web browser.
== Running (Apache) ==
- Make sure that your web server supports FastCGI. For Apache on OS X,
do this:
@@ -89,4 +107,4 @@ $ curl 'http://localhost/~bringert/gf-server/gf.fcgi/translate?input=this+fish&c
- Check server logs (e.g. /var/log/httpd/error_log) if it doesn't work.
- Go to SERVER_URL/gf-client.html in your web browser.
- Go to SERVER_URL/simple-client.html in your web browser.

View File

@@ -1,17 +1,36 @@
var gf = new Object();
var pgf_base_url = "pgf"
gf.translate = function (input,from,to,cat,callback) {
gf.httpGetText("gf.fcgi/translate?input="+escape(input)+"&from="+escape(from)+"&to="+escape(to)+"&cat="+escape(cat), function (output) { callback(gf.readJSON(output)); });
var args = [];
args["input"] = input;
args["from"] = from;
args["to"] = to;
args["cat"] = cat;
gf.callFunction("translate", args, callback);
};
gf.complete = function (input,from,cat,callback) {
gf.httpGetText("gf.fcgi/complete?input="+escape(input)+"&from="+escape(from)+"&cat="+escape(cat), function (output) { callback(gf.readJSON(output)); });
var args = [];
args["input"] = input;
args["from"] = from;
args["cat"] = cat;
gf.callFunction("complete", args, callback);
};
gf.languages = function (callback) {
gf.httpGetText("gf.fcgi/languages", function (output) { callback(gf.readJSON(output)); });
gf.grammar = function (callback) {
gf.callFunction("grammar", [], callback);
};
gf.callFunction = function (fun, args, callback) {
var query = "";
for (var i in args) {
query += (query == "") ? "?" : "&";
query += i + "=" + escape(args[i]);
}
gf.httpGetText(pgf_base_url + "/" + fun + query, function (output) { callback(gf.readJSON(output)); });
}
gf.httpGetText = function (url, callback) {
var XMLHttpRequestObject = false;

View File

@@ -6,7 +6,7 @@ license: GPL
license-file: LICENSE
synopsis: FastCGI Server for Grammatical Framework
executable gf.fcgi
executable pgf.fcgi
build-depends: base,
old-time,
unix,

View File

@@ -1,3 +1,3 @@
#!/bin/sh
APPDIR=`dirname $0`;
java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:/Users/bringert/src/gwt-mac-1.5.2/gwt-user.jar:/Users/bringert/src/gwt-mac-1.5.2/gwt-dev-mac.jar" com.google.gwt.dev.GWTShell -out "$APPDIR/www" -noserver "$@" http://localhost/~bringert/gwt-client/se.chalmers.cs.gf.gwt_translate.Translate/Translate.html;
java -XstartOnFirstThread -Xmx256M -cp "$APPDIR/src:$APPDIR/bin:/Users/bringert/src/gwt-mac-1.5.2/gwt-user.jar:/Users/bringert/src/gwt-mac-1.5.2/gwt-dev-mac.jar" com.google.gwt.dev.GWTShell -out "$APPDIR/www" -noserver "$@" http://localhost:41296/gwt-client/se.chalmers.cs.gf.gwt_translate.Translate/Translate.html;

View File

@@ -30,7 +30,7 @@ import java.util.Set;
public class Translate implements EntryPoint {
private static final String gfBaseURL = "/~bringert/gf-server/gf.fcgi";
private static final String gfBaseURL = "/pgf";
private GF gf;

78
src/server/lighttpd.conf Normal file
View File

@@ -0,0 +1,78 @@
#Run with (with -D for no-daemon)
# /usr/sbin/lighttpd -f lighttpd.conf -D
#
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_accesslog" )
var.basedir = var.CWD
server.document-root = basedir
## where to send error-messages to
server.errorlog = basedir + "/error.log"
# files to check for if .../ is requested
index-file.names = ( "index.php", "index.html",
"index.htm", "default.htm" )
## set the event-handler (read the performance section in the manual)
# server.event-handler = "freebsd-kqueue" # needed on OS X # Crashes on osx
server.event-handler = "poll"
#server.event-handler = "select"
# mimetype mapping
mimetype.assign = (
".gif" => "image/gif",
".jpg" => "image/jpeg",
".jpeg" => "image/jpeg",
".png" => "image/png",
".css" => "text/css",
".html" => "text/html",
".htm" => "text/html",
".js" => "text/javascript",
# default mime type
"" => "application/octet-stream",
)
accesslog.filename = basedir + "/access.log"
fastcgi.debug = 0
fastcgi.server = ( "/pgf" =>
( "localhost" =>
(
"socket" => "/tmp/fastcgi.socket",
"bin-path" => basedir + "/pgf.fcgi",
"bin-environment" => ("GHCRTS" => "-N2",
"PGF_FILE" => "grammar.pgf"),
"min-procs" => 1,
"max-procs" => 1,
"check-local" => "disable"
)
)
)
## deny access the file-extensions
#
# ~ is for backupfiles from vi, emacs, joe, ...
# .inc is often used for code includes which should in general not be part
# of the document-root
url.access-deny = ( "~", ".inc" )
$HTTP["url"] =~ "\.pdf$" {
server.range-requests = "disable"
}
##
# which extensions should not be handle via static-file transfer
#
# .php, .pl, .fcgi are most often handled by mod_fastcgi or mod_cgi
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
######### Options that are good to be but not neccesary to be changed #######
## bind to port (default: 80)
server.port = 41296

View File

@@ -22,9 +22,10 @@
gf.translate(input, fromLang, toLang, '', callback);
}
function populateLangs (langs) {
function populateLangs (grammar) {
var f = document.getElementById('fromLang');
var t = document.getElementById('toLang');
var langs = grammar.languages;
for (var i in langs) {
if (langs[i].canParse) {
addOption(f, langs[i].name, langs[i].name);
@@ -63,7 +64,7 @@
}
function initialize() {
gf.languages(populateLangs);
gf.grammar(populateLangs);
}
</script>
<title>AJAX GF Translator</title>