Skip to content

Commit 86c32ba

Browse files
committed
Implement rayvens-setup.sh --preload
1 parent ba241f9 commit 86c32ba

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

scripts/rayvens-setup.sh

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ while [ -n "$1" ]; do
4040
--cpu) shift; cpu=$1;;
4141
--mem) shift; mem=$1;;
4242
--example) example="1";;
43+
--preload) preload="1";;
4344

4445
--dev)
4546
kind="1";
@@ -76,6 +77,7 @@ Usage: rayvens-setup.sh [options]
7677
--kamel-options options to pass to Kamel install (to configure the container registry)
7778
--build build and push custom Rayvens container image from Rayvens source code in parent folder
7879
--example generate example file "example.py" in current working directory
80+
--preload preload main camel jars into maven repository
7981
8082
--kind setup a development Kind cluster on localhost instead of deploying to current Kubernetes context
8183
(destroy existing Kind cluster if any, set Kubernetes context to Kind)
@@ -85,6 +87,55 @@ EOF
8587
exit 0
8688
fi
8789

90+
if [ -n "$preload" ]; then
91+
tmp=$(mktemp -d)
92+
cat > "$tmp"/Preloader.java << EOF
93+
/*
94+
* Copyright IBM Corporation 2021
95+
*
96+
* Licensed under the Apache License, Version 2.0 (the "License");
97+
* you may not use this file except in compliance with the License.
98+
* You may obtain a copy of the License at
99+
*
100+
* http://www.apache.org/licenses/LICENSE-2.0
101+
*
102+
* Unless required by applicable law or agreed to in writing, software
103+
* distributed under the License is distributed on an "AS IS" BASIS,
104+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
105+
* See the License for the specific language governing permissions and
106+
* limitations under the License.
107+
*/
108+
109+
import org.apache.camel.BindToRegistry;
110+
import org.apache.camel.Exchange;
111+
import org.apache.camel.Processor;
112+
import org.apache.camel.builder.RouteBuilder;
113+
114+
class Exit implements Processor {
115+
public void process(Exchange exchange) throws Exception {
116+
System.exit(0);
117+
}
118+
}
119+
120+
public class Preloader extends RouteBuilder {
121+
@Override
122+
public void configure() throws Exception {
123+
from("timer:tick").to("bean:exit");
124+
from("platform-http:/null").to("http:null");
125+
}
126+
127+
@BindToRegistry
128+
public Exit exit() {
129+
return new Exit();
130+
}
131+
}
132+
EOF
133+
kamel local run "$tmp"/Preloader.java --dependency camel-k:loader-yaml
134+
rm "$tmp"/Preloader.java
135+
rmdir "$tmp"
136+
exit 0
137+
fi
138+
88139
if [ -z "$skip" ]; then
89140
echo "--- generating cluster configuration file"
90141
cat > "$config" << EOF

0 commit comments

Comments
 (0)