Permalink
Browse files

Add Tomcat 8 web server support to Freeciv-web. Resin will be depreca…

…ted from now on.
  • Loading branch information...
1 parent e02733d commit 505283fcf830bcc42099337b511d1752bfd9b558 @andreasrosdal andreasrosdal committed Mar 10, 2016
Showing with 158 additions and 215 deletions.
  1. +1 −1 Dockerfile
  2. +6 −4 README.md
  3. +1 −1 freeciv-earth/freeciv-earth-mapgen.py
  4. +28 −5 freeciv-web/README
  5. +2 −2 freeciv-web/build-js.sh
  6. +4 −3 freeciv-web/build.sh
  7. +1 −1 freeciv-web/src/main/java/org/freeciv/servlet/NewPBEMUser.java
  8. +7 −0 freeciv-web/src/main/webapp/META-INF/context.xml
  9. +15 −0 freeciv-web/src/main/webapp/WEB-INF/web.xml
  10. +1 −1 freeciv-web/src/main/webapp/meta/cleanup.php
  11. +0 −103 freeciv-web/src/main/webapp/meta/clients.phtml
  12. +1 −1 freeciv-web/src/main/webapp/meta/fpinfo.php
  13. +3 −3 freeciv-web/src/main/webapp/meta/fpmultimeta.php
  14. +6 −6 freeciv-web/src/main/webapp/meta/games-stats.php
  15. +9 −16 freeciv-web/src/main/webapp/meta/metaserver.php
  16. +1 −1 freeciv-web/src/main/webapp/meta/php_code/fallback_find_file.php
  17. +1 −1 freeciv-web/src/main/webapp/meta/php_code/fcdb.php
  18. +5 −3 freeciv-web/src/main/webapp/meta/php_code/local.php.dist
  19. +1 −1 freeciv-web/src/main/webapp/meta/php_code/php_code_find.php
  20. +14 −14 freeciv-web/src/main/webapp/meta/php_code/settings.php
  21. +3 −0 freeciv-web/src/main/webapp/meta/phpinfo.php
  22. +1 −1 freeciv-web/src/main/webapp/meta/status.php
  23. +1 −1 freeciv/patches/scorelog_filenames.patch
  24. +14 −6 publite2/nginx.conf
  25. +1 −1 publite2/publite2.py
  26. +1 −1 publite2/settings.ini.dist
  27. +0 −3 scripts/meta-sync.sh
  28. +12 −7 scripts/start-freeciv-web.sh
  29. +1 −1 scripts/status-freeciv-web.sh
  30. +8 −2 scripts/stop-freeciv-web.sh
  31. +6 −2 scripts/sync-js-hand.sh
  32. +1 −13 scripts/travis-build.sh
  33. +2 −10 scripts/vagrant-build.sh
View
@@ -3,7 +3,7 @@ FROM ubuntu:15.10
MAINTAINER The Freeciv Project version: 2.5
-RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get -y upgrade && apt-get install -y maven mysql-server openjdk-8-jdk libcurl4-openssl-dev nginx libjansson-dev subversion pngcrush python3-pillow libtool automake autoconf autotools-dev language-pack-en python3.5-dev python3-setuptools libbz2-dev imagemagick python3-pip dos2unix liblzma-dev firefox xvfb libicu-dev pkg-config zlib1g-dev wget curl libsdl1.2-dev sudo ca-certificates-java
+RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get -y upgrade && apt-get install -y maven mysql-server openjdk-8-jdk libcurl4-openssl-dev nginx libjansson-dev subversion pngcrush python3-pillow libtool automake autoconf autotools-dev language-pack-en python3.5-dev python3-setuptools libbz2-dev imagemagick python3-pip dos2unix liblzma-dev firefox xvfb libicu-dev pkg-config zlib1g-dev wget curl libsdl1.2-dev sudo ca-certificates-java tomcat8 tomcat8-admin php5-common php5-cli php5-fpm php5-mysql
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
View
@@ -25,7 +25,7 @@ Freeciv-Web consists of these components:
This application is a Java web application which make up the application
viewed in each user's web browser. The Metaserver is also a part of this module.
Implemented in Javascript, Java, JSP, PHP, HTML and CSS. Built with maven and runs
- on the Resin application server.
+ on Tomcat 8, nginx and php-fpm.
* [Freeciv](freeciv) - the Freeciv C server, which is checked out from the official
svn repository, and patched to work with a WebSocket/JSON protocol. Implemented in C.
@@ -127,9 +127,9 @@ System Requirements for manual install
Install this software if you are not running Freeciv-web with Vagrant:
-- Resin 4.0.x - http://www.caucho.com/
+- Tomcat 8 - https://tomcat.apache.org/
-- Java 7 JDK - http://www.oracle.com/technetwork/java/javase/downloads/
+- Java 8 JDK - http://www.oracle.com/technetwork/java/javase/downloads/
- Python 3.5 - http://www.python.org/
@@ -146,7 +146,9 @@ Install this software if you are not running Freeciv-web with Vagrant:
- OpenSSL - http://www.openssl.org/
-- nginx 1.6.0 or later - http://nginx.org/
+- nginx 1.9.0 or later - http://nginx.org/
+
+- PHP-FPM - FastCGI Process Manager for PHP - http://php-fpm.org/
- pngcrush, required for freeciv-img-extract. http://pmt.sourceforge.net/pngcrush/
@@ -25,7 +25,7 @@
import time
STATUS_PORT = 3999
-savedir = "../resin/webapps/data/savegames/";
+savedir = "/var/lib/tomcat8/webapps/data/savegames/";
savegame_filename = "freeciv-earth-savegame-";
savecounter = 10000;
savetemplate = "";
View
@@ -3,11 +3,34 @@ Freeciv web application
This is the Freeciv web application, which consists of the Java servlets
and filters for running the web client, JSP templates, javascript code
-and other web content.
-
-Requires Resin 4.0.x web server, and Maven to build and deploy.
-
-Run and compile:
+and other web content. There are also some PHP files in the meta directory
+which should be served with a PHP server.
+
+Tomcat 8 + nginx + PHP-FPM setup
+================================
+Freeciv-web supports the Tomcat 8 application server for hosting the Java web application.
+The PHP files in this webapp can be hosted using nginx and PHP-FPM
+(FastCGI Process Manager).
+
+The build scripts are updated to build Freeciv-web for Tomcat by default,
+so setting up Freeciv-web with Vagrant will configure this automatically.
+Also see the suggested nginx.conf file in publite2/nginx.conf
+
+https://tomcat.apache.org/
+http://nginx.org/
+http://php-fpm.org/
+
+Instead of serving PHP files with PHP-FPM, possibly also Apache2 with mod_php can be used.
+
+Resin
+=====
+The Resin 4 webapp server can also host Freeciv-web, both the Java webapp,
+JSP and PHP files. This setup is deprecated, but could work with some manual config.
+http://caucho.com/
+
+Build script
+============
+Use maven to build and deploy, by running this build script:
sh build.sh
The build script will also create a data webapp directory where savegames and scorelogs are stored.
@@ -1,4 +1,4 @@
#!/bin/bash
-# builds javascript files Freeciv-web and copies the resulting file to resin.
+# builds javascript files Freeciv-web and copies the resulting file to tomcat.
-mvn compile && cp target/freeciv-web/javascript/webclient.min.js ../resin/webapps/ROOT/javascript/
+mvn compile && cp target/freeciv-web/javascript/webclient.min.js /var/lib/tomcat8/webapps/ROOT/javascript/
@@ -1,8 +1,9 @@
#!/bin/bash
-# builds Freeciv-web and copies the war file to resin.
+# builds Freeciv-web and copies the war file to Tomcat.
+TOMCATDIR="/var/lib/tomcat8"
+DATADIR="/var/lib/tomcat8/webapps/data/"
ROOTDIR="$(pwd)/.."
-DATADIR="${ROOTDIR}/resin/webapps/data/"
( cd src/main/webapp/meta/private
./build_flagspec.sh ${ROOTDIR}/freeciv/freeciv/data/misc/flags.spec )
@@ -25,4 +26,4 @@ mkdir -p $DATADIR/savegames
mkdir -p $DATADIR/scorelogs
mkdir -p $DATADIR/ranklogs
-mvn package && cp target/freeciv-web.war "${ROOTDIR}/resin/webapps/ROOT.war"
+mvn package && cp target/freeciv-web.war "${TOMCATDIR}/webapps/ROOT.war"
@@ -53,7 +53,7 @@
public void init(ServletConfig config) throws ServletException {
super.init(config);
- captcha_secret = getServletContext().getInitParameter("captcha-secret");
+ captcha_secret = getInitParameter("captcha-secret");
}
@SuppressWarnings("unchecked")
@@ -0,0 +1,7 @@
+<Context>
+ <Resource name="jdbc/freeciv_mysql" auth="Container" type="javax.sql.DataSource"
+ maxActive="100" maxIdle="30" maxWait="10000"
+ username="root" password="vagrant" driverClassName="com.mysql.jdbc.Driver"
+ url="jdbc:mysql://localhost:3306/freeciv_web"/>
+
+</Context>
@@ -5,6 +5,15 @@
<display-name>Freeciv-web Client</display-name>
+
+ <resource-ref>
+ <description>MySQL DB Connection</description>
+ <res-ref-name>jdbc/freeciv_mysql</res-ref-name>
+ <res-type>javax.sql.DataSource</res-type>
+ <res-auth>Container</res-auth>
+ </resource-ref>
+
+
<!-- /civclientlauncher (game launcher servlet) -->
<servlet>
<servlet-name>CivclientLauncher</servlet-name>
@@ -45,6 +54,12 @@
<servlet>
<servlet-name>NewPBEMUser</servlet-name>
<servlet-class>org.freeciv.servlet.NewPBEMUser</servlet-class>
+ <!-- this is the secret key from Google Recaptcha. -->
+ <init-param>
+ <param-name>captcha-secret</param-name>
+ <param-value>google captcha secret goes here!</param-value>
+ </init-param>
+
</servlet>
<servlet-mapping>
@@ -14,7 +14,7 @@
$config_problem = true;
}
-if (! $config_problem) {
+if (!isset($config_problem)) {
include_once("php_code/php_code_find.php");
// includes for support routines
include_once(php_code_find("fcdb.php"));
@@ -1,103 +0,0 @@
-<!-- This is for the HTML validator -->
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-<!-- The real code begins here -->
-
-<?php
- // include the php-code finder
- ini_set("include_path",
- ini_get("include_path") . ":" . $_SERVER["DOCUMENT_ROOT"]
- );
- include_once("php_code/settings.php");
- include_once("php_code/php_code_find.php");
- // includes for support routines
- include_once(php_code_find("fcdb.php"));
- include_once(php_code_find("img.php"));
-?>
-
-<HTML>
-<HEAD>
-<TITLE>Freeciv Client Stats</TITLE>
-<META HTTP-EQUIV=Content-Language CONTENT=en>
-</HEAD>
-
-<BODY BGCOLOR="#FFFAF0">
-
-<?
-echo "<CENTER>";
-img_html("headers/clients.gif", "Client Statistics", NULL, NULL);
-echo "</CENTER><BR><CENTER>";
-
-$start = "start";
-if ( isset($_REQUEST[$start]) ) {
- $where[]="date >= \"$_REQUEST[$start]\"";
-}
-$end = "end";
-if ( isset($_REQUEST[$end]) ) {
- $where[]="date <= \"$_REQUEST[$end]\"";
-}
-$list=array("version","gui","os","arch","tileset");
-foreach ($list as $type) {
- if ( isset($_REQUEST[$type]) ) {
- $where[]="$type = \"$_REQUEST[$type]\"";
- }
-}
-
-if ( $where[0] ) {
- $swhere="where ". join(" and ", $where);
-}
-
-fcdb_default_connect();
-
-$stmt="select sum(count) from clients $swhere";
-$total=fcdb_query_single_value($stmt);
-
-foreach ($list as $type) {
- echo "<TABLE BORDER BGCOLOR=\"#9FB6CD\">\n";
- echo "<TR><TH>$type</TH><TH>Count</TH><TH COLSPAN=2>Percentage</TR>\n"; echo "<TR></TR>\n";
-
- $stmt="select distinct $type from clients $swhere order by $type";
- $res = fcdb_exec($stmt);
- for ( $inx = 0; $inx < fcdb_num_rows($res); $inx++ ) {
- $row = fcdb_fetch_array($res, $inx);
- if ( $swhere ) {
- $cond="$swhere and $type='$row[$type]'";
- } else {
- $cond="where $type='$row[$type]'";
- }
- $stmt="select sum(count) from clients $cond";
- /* echo "\n\n<!-- query $stmt -->\n"; */
- $count=fcdb_query_single_value($stmt);
- $l=round($count*100/$total+.0001);
- echo "<TR><TD ALIGN=\"LEFT\">";
- if ( $row[$type] == "" ) {
- echo "Unknown";
- } else {
- echo $row[$type];
- }
- echo "</TD><TD ALIGN=\"RIGHT\">";
- echo $count;
- echo "</TD><TD ALIGN=LEFT>";
- $img_tag_extra= "height=\"16\" width=\"" . strval($l*6+1) . "\"";
- img_html("line.png", NULL, "$img_tag_extra", NULL);
- echo "<TD ALIGN=RIGHT>$l%</TD></TR>\n";
- }
- echo "</TABLE><BR>";
-}
-
-?>
-</CENTER>
-
-<BR>
-<HR>Return to <a href="/">the main page</A>
-<HR>In case of technical problems, please contact
-<?php echo $webmaster_html ?>.
-
-<BR><BR>
-<P ALIGN="center">
-<?
-img_html("hr.gif", "--------", NULL, NULL);
-?>
-<BR><BR>
-
-</BODY>
-</HTML>
@@ -9,7 +9,7 @@
$config_problem = true;
}
-if (! $config_problem) {
+if (!isset($config_problem)) {
include_once("php_code/php_code_find.php");
// includes for support routines
include_once(php_code_find("fcdb.php"));
@@ -14,7 +14,7 @@
$config_problem = true;
}
-if (! $config_problem) {
+if (!isset($config_problem)) {
include_once("php_code/php_code_find.php");
// includes for support routines
include_once(php_code_find("fcdb.php"));
@@ -28,7 +28,7 @@
?>
<h3>Multiplayer Games</h3>
-<?
+<?php
$stmt="(select host,port,version,patches,state,message,unix_timestamp()-unix_timestamp(stamp), (select value from variables where name = 'turn' and hostport = CONCAT(s.host ,':',s.port)) as turn from servers s where message not like '%Private%' and type = 'multiplayer' and state = 'Running' order by state desc) UNION (select host,port,version,patches,state,message,unix_timestamp()-unix_timestamp(stamp), (select value from variables where message not like '%Private%' and name = 'turn' and hostport = CONCAT(s.host ,':',s.port)) as turn from servers s where message not like '%Private%' and type = 'multiplayer' and state = 'Pregame' and CONCAT(s.host ,':',s.port) in (select hostport from players where type <> 'A.I.') limit 1) UNION (select host,port,version,patches,state,message,unix_timestamp()-unix_timestamp(stamp), (select value from variables where name = 'turn' and hostport = CONCAT(s.host ,':',s.port)) as turn from servers s where type = 'multiplayer' and state = 'Pregame' limit 2)";
$res = fcdb_exec($stmt);
$nr = fcdb_num_rows($res);
@@ -85,7 +85,7 @@
}
print "</td><td style=\"width: 30%\" >";
print db2html($row["message"]);
- print "</td><td>"
+ print "</td><td>";
print db2html($row["turn"]);
print "</td></tr>\n";
@@ -11,7 +11,7 @@
$config_problem = true;
}
-if (! $config_problem) {
+if (!isset($config_problem)) {
include_once("php_code/php_code_find.php");
// includes for support routines
include_once(php_code_find("fcdb.php"));
@@ -31,15 +31,15 @@
$row = fcdb_fetch_array($res, $inx);
print db2html($row["sd"]);
- print ","
+ print ",";
print db2html($row["web_single"]);
- print ","
+ print ",";
print db2html($row["web_multi"]);
- print ","
+ print ",";
print db2html($row["web_pbem"]);
- print ","
+ print ",";
print db2html($row["desktop_multi"]);
- print ";"
+ print ";";
}
Oops, something went wrong.

0 comments on commit 505283f

Please sign in to comment.