Android Build
System - Jack Server : How to support Multi User environment
#android_jack-server_multi-user
OS : Android 7.1
OS : Android 7.1
Single Build machine & Multi user 환경에서의 Android platform build 시 자동으로 사용자별(user id를 참조하여) jack-server를 구동하는 방법에 대해 기록한다.
- https://github.com/whitemuse/aosp-jack-server
Jack
limitations (https://source.android.com/setup/build/jack)
By default, the Jack server is mono-user and can be only one user on
a computer. To support additional users, select different port number for each
user and adjust SERVER_NB_COMPILE accordingly. You can also disable the Jack
server by setting SERVER=false in $HOME/.jack
웹 검색을 통해 사용자 별 Jack Server의 포트설정을 다르게 사용하는 것으로 해결이 가능함을 확인 할 수 있다. 다만, jack server 동작을 위한 설정파일($HOME/.jack-server/config.properties, $HOME/.jack-settings) 을 수동으로 편집해야 하는 불편함이 따른다. Build 시 자동으로 설정되도록 아래와 같이 수정한다.
-----------------------------------------------------------------------------------------
Runtime port 설정변경 & New jack server start
1. android/prebuilts/sdk/tools/jack
33 #####################################################
34 # TEAM - SISBSOMA
35 PORT_OFFSET=`id -u`
36 SERVER_PORT_SERVICE=`expr 8076 + ${PORT_OFFSET}`
37 SERVER_PORT_ADMIN=`expr 8077 + ${PORT_OFFSET}`
38 #####################################################
2. android/prebuilts/sdk/tools/jack-admin
45
#####################################################
46 # TEAM - SISBSOMA
47 PORT_OFFSET=`id -u`
48 SERVER_PORT_SERVICE_DEFAULT=8076
49
SERVER_PORT_ADMIN_DEFAULT=8077
50
51 SERVER_PORT_SERVICE=`expr
8076 + ${PORT_OFFSET}`
52 SERVER_PORT_ADMIN=`expr
8077 + ${PORT_OFFSET}`
53
######################################################
54
55 #####################################################
56 # TEAM - SISBSOMA
57 updatePortNum() {
58 echo "Update Port Number - Jack
Sever"
59 T_P=`grep SERVER_PORT_SERVICE
~/.jack-settings | cut -d'=' -f2`
60 if [ "$T_P" -ne
"$SERVER_PORT_SERVICE" ]; then
61 if [ -f "$CLIENT_SETTING" ];
then
62 sed -i
's/SERVER_PORT_SERVICE.*/SERVER_PORT_SERVICE='$SERVER_PORT_SERVICE'/g'
$CLIENT_SETTING
63 sed -i
's/SERVER_PORT_ADMIN.*/SERVER_PORT_ADMIN='$SERVER_PORT_ADMIN'/g'
$CLIENT_SETTING
64 fi
65 fi
66 if [
-d "$JACK_HOME" ]; then
67 sed -i
's/jack.server.service.port.*/jack.server.service.port='$SERVER_PORT_SERVICE'/g'
"$JACK_HOME/config.properties"
68 sed -i
's/jack.server.admin.port.*/jack.server.admin.port='$SERVER_PORT_ADMIN'/g'
"$JACK_HOME/config.properties"
69 fi
70 }
71
#####################################################
216 waitServerStarted () {
217 DONE=1
218 let DATE_TIMEOUT=$(date
+%s)+$JACK_CONNECTION_TIMEOUT
219 while [
"$DONE" -ne 0 ]; do
220 HTTP_CODE=$(curl -f
$JACK_EXTRA_CURL_OPTIONS \
221 --cert
"${JACK_HOME}/client.pem" \
222 --cacert
"${JACK_HOME}/server.pem" \
223 --output
/dev/null \
224 --no-buffer
--write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT
\
225 -X GET \
226 -H "Accept:
text/plain$CHARSET_ARGUMENT" \
227 --noproxy
${SERVER_HOST} \
228
https://${SERVER_HOST}:$SERVER_PORT_ADMIN/server \
229 )
230 CURL_CODE=$?
231 if [ $CURL_CODE -eq 7
] || [ $CURL_CODE -eq 35 ] || [ $CURL_CODE -eq 58 ] || [ $CURL_CODE -eq 60 ] ||
[ $CURL_CODE -eq 77 ]; then
232 if [ $(date +%s) -ge
$DATE_TIMEOUT ]; then
233 echo "Jack
server failed to (re)start, try 'jack-diagnose' or see Jack server log"
>&2
234 abort
235 else
236
#####################################################
237 # TEAM - SISBSOMA
238 if [
"$CURL_CODE" -eq 7 ]; then
239 if [ -f
"$JACK_HOME/config.properties" ]; then
240 JSSP=`grep
"jack.server.service.port" "$JACK_HOME/config.properties" |
cut -d'=' -f2`
241 if [
"$JSSP" -ne "$SERVER_PORT_SERVICE" ]; then
242 echo
"@@ (New) Jack Server start~!!"
243
updatePortNum
244
funcStartServer
245
funcStopServer $JSSP
246 fi
247 fi
248 fi
249
#####################################################
250 sleep 1
251 fi
252 else
253 # A connection was
opened, no need to know if it went well
254 DONE=0;
255 fi
256 done
257 }
278 funcStopServer() {
279 echo "Stopping
background server : $1"
280 HTTP_CODE=$(curl -f
$JACK_EXTRA_CURL_OPTIONS \
281 --cert
"${JACK_HOME}/client.pem" \
282 --cacert
"${JACK_HOME}/server.pem" \
283 --output
/dev/null \
284 --no-buffer
--write-out '%{http_code}' --silent --connect-timeout $JACK_CONNECTION_TIMEOUT
\
285 -X POST \
286 --noproxy
${SERVER_HOST} \
287
https://${SERVER_HOST}:$1/server/stop \
288 )
289
290 handleHttpErrors $?
$HTTP_CODE
291 }
292
293 funcStartServer() {
294
JACK_SERVER_COMMAND="java -XX:MaxJavaStackTraceDepth=-1
-Djava.io.tmpdir=$TMPDIR $JACK_SERVER_VM_ARGUMENTS -cp $LAUNCHER_JAR
$LAUNCHER_NAME"
295 echo "Launching
Jack server" $JACK_SERVER_COMMAND
296 (
297 trap ""
SIGHUP
298 for i in $(seq 3
255); do
299 eval exec
"$i"'>&-'
300 done
301 cd
"$JACK_HOME"
302 umask $BASE_UMASK
303 exec
$JACK_SERVER_COMMAND
304 abort
305 )
>"$JACK_OUT_ERR" 2>&1 &
306 }
감사합니다. 도움 받았습니다.
답글삭제