mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-21 22:43:01 +00:00
nixos/tomcat: add 'port' option
This commit is contained in:
parent
31a5a35b7e
commit
a8da5dbf32
@ -21,6 +21,14 @@ in
|
||||
example = "tomcat10";
|
||||
};
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 8080;
|
||||
description = ''
|
||||
The TCP port Tomcat should listen on.
|
||||
'';
|
||||
};
|
||||
|
||||
purifyOnStart = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
@ -244,8 +252,12 @@ in
|
||||
hostElementsString = lib.concatMapStringsSep "\n" hostElementForVirtualHost cfg.virtualHosts;
|
||||
hostElementsSedString = lib.replaceStrings ["\n"] ["\\\n"] hostElementsString;
|
||||
in ''
|
||||
# Create a modified server.xml which also includes all virtual hosts
|
||||
sed -e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\\"${lib.escapeShellArg hostElementsSedString} \
|
||||
# Create a modified server.xml which listens on the given port,
|
||||
# and also includes all virtual hosts.
|
||||
# The host modification must be last here,
|
||||
# else if hostElementsSedString is empty sed gets confused as to what to append
|
||||
sed -e 's/<Connector port="8080"/<Connector port="${toString cfg.port}"/' \
|
||||
-e "/<Engine name=\"Catalina\" defaultHost=\"localhost\">/a\\"${lib.escapeShellArg hostElementsSedString} \
|
||||
${tomcat}/conf/server.xml > ${cfg.baseDir}/conf/server.xml
|
||||
''
|
||||
}
|
||||
|
@ -5,23 +5,24 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
||||
nodes.machine = { pkgs, ... }: {
|
||||
services.tomcat = {
|
||||
enable = true;
|
||||
port = 8001;
|
||||
axis2.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
machine.wait_for_unit("tomcat.service")
|
||||
machine.wait_for_open_port(8080)
|
||||
machine.wait_for_open_port(8001)
|
||||
machine.wait_for_file("/var/tomcat/webapps/examples");
|
||||
|
||||
machine.succeed(
|
||||
"curl -sS --fail http://localhost:8080/examples/servlets/servlet/HelloWorldExample | grep 'Hello World!'"
|
||||
"curl -sS --fail http://localhost:8001/examples/servlets/servlet/HelloWorldExample | grep 'Hello World!'"
|
||||
)
|
||||
machine.succeed(
|
||||
"curl -sS --fail http://localhost:8080/examples/jsp/jsp2/simpletag/hello.jsp | grep 'Hello, world!'"
|
||||
"curl -sS --fail http://localhost:8001/examples/jsp/jsp2/simpletag/hello.jsp | grep 'Hello, world!'"
|
||||
)
|
||||
machine.succeed(
|
||||
"curl -sS --fail http://localhost:8080/axis2/axis2-web/HappyAxis.jsp | grep 'Found Axis2'"
|
||||
"curl -sS --fail http://localhost:8001/axis2/axis2-web/HappyAxis.jsp | grep 'Found Axis2'"
|
||||
)
|
||||
'';
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user