Skip to content

Commit 1a89813

Browse files
authored
Updated Linux start scripts to be called membrane.sh, migrated Window… (membrane#1574)
* Updated Linux start scripts to be called membrane.sh, migrated Windows scripts to CMD from PS1. * Ammend * Ammend * Fixed example test startup mechanism for windows * Ammend * Load balancing example test windows scripts fixes * Windows paths with spaces fix on RouterCLI proxies.xml resolving * Quickfix * Fix Windows main starter script
1 parent 1bb4751 commit 1a89813

File tree

367 files changed

+8354
-6192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

367 files changed

+8354
-6192
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ A versatile and lightweight **API Gateway** for **REST** and **legacy SOAP Web S
9393
2. **Start the Gateway**
9494
- Open a terminal in the extracted directory.
9595
- Run the appropriate command for your operating system:
96-
- **Linux/Mac:** `./service-proxy.sh`
97-
- **Windows:** `service-proxy.ps1`
96+
- **Linux/Mac:** `./membrane.sh`
97+
- **Windows:** `membrane.cmd`
9898

9999
3. **Access the Gateway**
100100
- Open your browser and navigate to [http://localhost:2000](http://localhost:2000).

core/src/main/java/com/predic8/membrane/core/cli/MembraneCommandLine.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ private static Options getRootOptions() {
3333
}
3434

3535
private static @NotNull CliCommand getRootNamespace(Options rootOptions) {
36-
return new CliCommand("service-proxy.sh", "Membrane Service Proxy") {{
36+
return new CliCommand("membrane.sh", "Membrane Service Proxy") {{
3737
setOptions(rootOptions);
3838

3939
addExample("Start gateway configured from OpenAPI file",
40-
"service-proxy.sh oas -l conf/fruitshop-api.yml")
40+
"membrane.sh oas -l conf/fruitshop-api.yml")
4141
.addExample("Start gateway configured from OpenAPI URL and validate requests",
42-
"service-proxy.sh oas -v -l https://api.predic8.de/shop/v2/api-docs");
42+
"membrane.sh oas -v -l https://api.predic8.de/shop/v2/api-docs");
4343

4444
addSubcommand(new CliCommand("start", " (Default) Same function as command omitted. Start gateway with configuration from proxies.xml") {{
4545
setOptions(rootOptions);

core/src/main/java/com/predic8/membrane/core/cli/RouterCLI.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import static com.predic8.membrane.core.openapi.serviceproxy.OpenAPISpec.YesNoOpenAPIOption.*;
3333
import static com.predic8.membrane.core.util.ExceptionUtil.concatMessageAndCauseMessages;
3434
import static com.predic8.membrane.core.util.OSUtil.*;
35+
import static com.predic8.membrane.core.util.URIUtil.pathFromFileURI;
3536
import static java.lang.Integer.*;
3637

3738
public class RouterCLI {
@@ -171,21 +172,21 @@ private static boolean shouldResolveFile(String s) {
171172
}
172173

173174
private static String getRulesFileFromRelativeSpec(ResolverMap rm, String relativeFile, String errorNotice) {
174-
String try1 = ResolverMap.combine(prefix(getUserDir()), relativeFile);
175+
String try1 = pathFromFileURI(ResolverMap.combine(prefix(getUserDir()), relativeFile));
175176
try(InputStream ignored = rm.resolve(try1)) {
176177
return try1;
177178
} catch (Exception e) {
178-
// ignored
179+
log.error("Could not resolve path to configuration (attempt 1).", e);
179180
}
180181

181182
String membraneHome = System.getenv(MEMBRANE_HOME);
182183
String try2 = null;
183184
if (membraneHome != null) {
184-
try2 = ResolverMap.combine(prefix(membraneHome), relativeFile);
185+
try2 = pathFromFileURI(ResolverMap.combine(prefix(membraneHome), relativeFile));
185186
try(InputStream ignored = rm.resolve(try2)) {
186187
return try2;
187188
} catch (Exception e) {
188-
// ignored
189+
log.error("Could not resolve path to configuration (attempt 2).", e);
189190
}
190191
}
191192
System.err.println("Could not find Membrane's configuration file at " + try1 + (try2 == null ? "" : " and not at " + try2) + " . " + errorNotice);

core/src/main/java/com/predic8/membrane/core/interceptor/shutdown/ShutdownInterceptor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* </p>
3030
* <p>
3131
* Has undefined behavior when Membrane is <b>not</b> started from command line
32-
* (=via the RouterCLI class, which <tt>service-proxy.ps1</tt>/<tt>service-proxy.sh</tt>
32+
* (=via the RouterCLI class, which <tt>membrane.cmd</tt>/<tt>membrane.sh</tt>
3333
* do use).
3434
* </p>
3535
* <p>

distribution/docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ RUN groupadd --gid $USER_GID $USERNAME && useradd --uid $USER_UID --gid $USER_GI
1717

1818
USER $USERNAME
1919
WORKDIR /opt/membrane
20-
ENTRYPOINT ["./service-proxy.sh"]
20+
ENTRYPOINT ["./membrane.sh"]

distribution/examples/acl/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ To run the example execute the following steps:
1313

1414
1. Go to the `examples/acl` directory.
1515

16-
2. Execute `service-proxy.ps1`
16+
2. Execute `membrane.cmd`
1717

1818
3. Open the URL http://localhost:2000/ in your browser.
1919
The predic8.de website will be displayed in your browser.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
@echo off
2+
setlocal EnableDelayedExpansion
3+
4+
set "exitcode=0"
5+
set "required_version=21"
6+
7+
where java >nul 2>&1
8+
if errorlevel 1 (
9+
echo Java is not installed. Membrane needs at least Java %required_version%.
10+
set "exitcode=1"
11+
goto finish
12+
)
13+
14+
for /f "usebackq tokens=3 delims= " %%A in (`java -version 2^>^&1 ^| findstr /i "version"`) do (
15+
set "full_version=%%A"
16+
goto :versionFound
17+
)
18+
19+
:versionFound
20+
if not defined full_version (
21+
echo WARNING: Could not determine Java version. Make sure Java version is at least %required_version%. Proceeding anyway...
22+
goto startMembrane
23+
)
24+
set "full_version=%full_version:"=%"
25+
26+
for /f "delims=." %%B in ("%full_version%") do (
27+
set "current_version=%%B"
28+
)
29+
30+
for /f "delims=0123456789" %%C in ("!current_version!") do (
31+
set "nonNumeric=%%C"
32+
)
33+
if defined nonNumeric (
34+
echo WARNING: Could not parse Java version. Make sure your Java version is at least %required_version%. Proceeding anyway...
35+
goto startMembrane
36+
)
37+
38+
if %current_version% GEQ %required_version% (
39+
goto startMembrane
40+
) else (
41+
echo Java version mismatch: Required=%required_version%, Installed=%full_version%
42+
set "exitcode=1"
43+
goto finish
44+
)
45+
46+
:findMembraneDirectory
47+
set "test_dir=%~1"
48+
if exist "%test_dir%\conf" if exist "%test_dir%\lib" (
49+
set "membrane_home=%test_dir%"
50+
goto :eof
51+
)
52+
53+
if "%test_dir:~1%"==":\" (
54+
goto :eof
55+
)
56+
57+
for %%A in ("%test_dir%") do set "parent=%%~dpA"
58+
if not "%parent:~0,3%"=="%parent%" (
59+
set "parent=%parent:~0,-1%"
60+
)
61+
if /i "%parent%"=="%test_dir%" (
62+
goto :eof
63+
)
64+
call :findMembraneDirectory "%parent%"
65+
goto :eof
66+
67+
:startMembrane
68+
set "current=%CD%"
69+
set "membrane_home="
70+
71+
call :findMembraneDirectory "%current%"
72+
73+
if defined membrane_home (
74+
call :startMembraneService "%membrane_home%"
75+
set "exitcode=0"
76+
goto finish
77+
) else (
78+
echo Could not start Membrane. Ensure the directory structure is correct.
79+
set "exitcode=1"
80+
goto finish
81+
)
82+
83+
:startMembraneService
84+
set "membrane_home=%~1"
85+
set "MEMBRANE_HOME=%membrane_home%"
86+
set "CLASSPATH=%membrane_home%\conf;%membrane_home%\lib\*"
87+
echo Starting: %membrane_home% CL: %CLASSPATH%
88+
java -cp "%CLASSPATH%" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
89+
goto :eof
90+
91+
:finish
92+
pause
93+
exit /b %exitcode%

distribution/examples/acl/service-proxy.ps1

Lines changed: 0 additions & 69 deletions
This file was deleted.

distribution/examples/apikey/store/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ A quick guide to setting up a JDBC-based API key store using PostgreSQL.
5353
4. **run service.proxy.sh script:**
5454

5555
```shell
56-
./service-proxy.sh
56+
./membrane.sh
5757
```
5858

5959
5. **Run SQL File in your Docker Container**
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
@echo off
2+
setlocal EnableDelayedExpansion
3+
4+
set "exitcode=0"
5+
set "required_version=21"
6+
7+
where java >nul 2>&1
8+
if errorlevel 1 (
9+
echo Java is not installed. Membrane needs at least Java %required_version%.
10+
set "exitcode=1"
11+
goto finish
12+
)
13+
14+
for /f "usebackq tokens=3 delims= " %%A in (`java -version 2^>^&1 ^| findstr /i "version"`) do (
15+
set "full_version=%%A"
16+
goto :versionFound
17+
)
18+
19+
:versionFound
20+
if not defined full_version (
21+
echo WARNING: Could not determine Java version. Make sure Java version is at least %required_version%. Proceeding anyway...
22+
goto startMembrane
23+
)
24+
set "full_version=%full_version:"=%"
25+
26+
for /f "delims=." %%B in ("%full_version%") do (
27+
set "current_version=%%B"
28+
)
29+
30+
for /f "delims=0123456789" %%C in ("!current_version!") do (
31+
set "nonNumeric=%%C"
32+
)
33+
if defined nonNumeric (
34+
echo WARNING: Could not parse Java version. Make sure your Java version is at least %required_version%. Proceeding anyway...
35+
goto startMembrane
36+
)
37+
38+
if %current_version% GEQ %required_version% (
39+
goto startMembrane
40+
) else (
41+
echo Java version mismatch: Required=%required_version%, Installed=%full_version%
42+
set "exitcode=1"
43+
goto finish
44+
)
45+
46+
:findMembraneDirectory
47+
set "test_dir=%~1"
48+
if exist "%test_dir%\conf" if exist "%test_dir%\lib" (
49+
set "membrane_home=%test_dir%"
50+
goto :eof
51+
)
52+
53+
if "%test_dir:~1%"==":\" (
54+
goto :eof
55+
)
56+
57+
for %%A in ("%test_dir%") do set "parent=%%~dpA"
58+
if not "%parent:~0,3%"=="%parent%" (
59+
set "parent=%parent:~0,-1%"
60+
)
61+
if /i "%parent%"=="%test_dir%" (
62+
goto :eof
63+
)
64+
call :findMembraneDirectory "%parent%"
65+
goto :eof
66+
67+
:startMembrane
68+
set "current=%CD%"
69+
set "membrane_home="
70+
71+
call :findMembraneDirectory "%current%"
72+
73+
if defined membrane_home (
74+
call :startMembraneService "%membrane_home%"
75+
set "exitcode=0"
76+
goto finish
77+
) else (
78+
echo Could not start Membrane. Ensure the directory structure is correct.
79+
set "exitcode=1"
80+
goto finish
81+
)
82+
83+
:startMembraneService
84+
set "membrane_home=%~1"
85+
set "MEMBRANE_HOME=%membrane_home%"
86+
set "CLASSPATH=%membrane_home%\conf;%membrane_home%\lib\*"
87+
echo Starting: %membrane_home% CL: %CLASSPATH%
88+
java -cp "%CLASSPATH%" com.predic8.membrane.core.cli.RouterCLI -c proxies.xml
89+
goto :eof
90+
91+
:finish
92+
pause
93+
exit /b %exitcode%

0 commit comments

Comments
 (0)