summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbjorn <bjorn@bringert.net>2008-10-20 12:56:08 +0000
committerbjorn <bjorn@bringert.net>2008-10-20 12:56:08 +0000
commit9b8f50534c6497ee54c7eb90bf022010fc803dca (patch)
treec78f039c405d06e2cc512c9d8e46ba5430389fff
parentcec2b61af0a9dc392df20dbb601bb33858aac502 (diff)
Update gf-server instructions and configuration.
-rw-r--r--src/server/Makefile5
-rw-r--r--src/server/README42
-rw-r--r--src/server/gf-server-jsapi.js5
-rw-r--r--src/server/lighttpd.conf5
-rw-r--r--src/server/simple-client.html2
5 files changed, 33 insertions, 26 deletions
diff --git a/src/server/Makefile b/src/server/Makefile
index fe37ee114..76f1d1ab8 100644
--- a/src/server/Makefile
+++ b/src/server/Makefile
@@ -3,15 +3,14 @@ GFCFLAGS = +RTS -K100M -RTS --cpu
.PHONY: pgf.fcgi run
pgf.fcgi:
- cabal configure
- cabal build
+ cabal install
cp dist/build/pgf.fcgi/pgf.fcgi .
gwt:
gwt-client/Translate-compile
food.pgf:
- gfc --make --name=grammar ../../examples/tutorial/food/Food{Eng,Ita}.gf
+ gfc --make --name=food ../../examples/tutorial/food/Food{Eng,Ita}.gf
Demo%-parse.pgf: ../../lib/resource/demo/Demo%.gf
gfc $(GFCFLAGS) --make --erasing=on --name=Demo$*-parse $^
diff --git a/src/server/README b/src/server/README
index 7e93cd41f..de3b19a20 100644
--- a/src/server/README
+++ b/src/server/README
@@ -1,49 +1,55 @@
== Requirements ==
-- cabal
+- cabal-install
* See quick installation instructions at the bottom of
http://hackage.haskell.org/trac/hackage/wiki/CabalInstall
- FastCGI development kit
- * MacPorts: sudo port install fcgi
-
-- Haskell packages: fastcgi, json, utf8-string
- * cabal install fastcgi json utf8-string
+ (MacPorts) $ sudo port install fcgi
- GF installed as a Cabal package
- * (cd ../.. && cabal install)
- * Maybe need to remove "-beta" from the Version field in ../../GF.cabal
+ $ (cd ../.. && cabal install)
-== Building ==
-- Build gf.fcgi
+== Building ==
-$ make
+- Build pgf.fcgi. This will use cabal to install the dependencies (cgi, fastcgi, json, utf8-string).
+ $ make
- Build small example grammar:
-
-$ make food
-
+ $ make food.pgf
+ $ cp food.pgf grammar.pgf
== Running (lighttpd) ==
- Install lighttpd
- - MacPorts:
- $ sudo port install lighttpd
+ (MacPorts) $ sudo port install lighttpd
- Run lighttpd:
- $ lighttpd -f lighttpd.conf -D
+ $ make run
+
+
+== Testing ==
- 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'
+ $ curl 'http://localhost:41296/pgf/grammar.pgf/translate?input=this+fish&cat=Item&from=FoodEng'
+
+- Non-GWT AJAX UI:
+ See http://localhost:41296/simple-client.html
+
+- GWT AJAX UI:
+ See http://localhost:41296/gwt-client/www/se.chalmers.cs.gf.gwt_translate.Translate/Translate.html
+
+
-- Go to http://localhost:41296/simple-client.html in your web browser.
== Running (Apache) ==
+Note: This is more complicated, and the instructions may not be up to date.
+
- Make sure that your web server supports FastCGI. For Apache on OS X,
do this:
diff --git a/src/server/gf-server-jsapi.js b/src/server/gf-server-jsapi.js
index 26b41575a..bd55c42d3 100644
--- a/src/server/gf-server-jsapi.js
+++ b/src/server/gf-server-jsapi.js
@@ -1,5 +1,6 @@
var gf = new Object();
-var pgf_base_url = "pgf"
+var pgf_base_url = "pgf";
+var pgf_grammar = "grammar.pgf";
gf.translate = function (input,from,to,cat,callback) {
var args = [];
@@ -28,7 +29,7 @@ gf.callFunction = function (fun, args, callback) {
query += (query == "") ? "?" : "&";
query += i + "=" + encodeURIComponent(args[i]);
}
- var url = pgf_base_url + "/" + fun + query;
+ var url = pgf_base_url + "/" + pgf_grammar +"/" + fun + query;
// FIXME: if same domain, use gf.httpGetText
gf.httpGetJSONP(url, callback);
diff --git a/src/server/lighttpd.conf b/src/server/lighttpd.conf
index aacb2659b..e93e63692 100644
--- a/src/server/lighttpd.conf
+++ b/src/server/lighttpd.conf
@@ -43,8 +43,9 @@ fastcgi.server = ( "/pgf" =>
((
"socket" => "/tmp/lighttpd-pgf.socket",
"bin-path" => basedir + "/pgf.fcgi",
- "bin-environment" => ("GHCRTS" => "-N2",
- "PGF_FILE" => "grammar.pgf"),
+ # Use 2 OS threads (to be able to use 2 cores).
+ # Limit heap size to 512 MB.
+ "bin-environment" => ("GHCRTS" => "-N2 -M512M"),
"min-procs" => 1,
"max-procs" => 1,
"broken-scriptfilename" => "disable",
diff --git a/src/server/simple-client.html b/src/server/simple-client.html
index 5d320acdb..7c6c0da0f 100644
--- a/src/server/simple-client.html
+++ b/src/server/simple-client.html
@@ -73,7 +73,7 @@
<div id="translator">
<form onsubmit="update(); return false;">
<p>
- <input type="text" id="inputText" value="determine the sine of 1 ." size="50" />
+ <input type="text" id="inputText" value="" size="50" />
</p>
<p>
<label>From: <select id="fromLang" onchange="update()"><option value="" selected="selected">Any language</option></select></label>