Appinventor服務器搭建
準備工作
任務時間:時間未知
10min ~ 20min
升級系統至最新
yum -y update
必要軟件安裝
yum -y install wget zip unzip git vim zlib.i686 libstdc++-4.8.5-28.el7.i686 libstdc++-4.8.5-28.el7_5.1.i686 git
yum provides libstdc++.so.6
yum -y install libstdc++-4.8.5-28.el7.i686
下載與安裝jdk8
cd /opt
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/8u191-b12/2787e4a523244c269598db4e85c51e0c/jdk-8u191-linux-x64.tar.gz
tar -zxvf jdk-8u191-linux-x64.tar.gz
ln -s /opt/jdk1.8.0_191 /opt/java
Ant安裝
cd /opt
wget http://mirrors.hust.edu.cn/apache//ant/binaries/apache-ant-1.10.5-bin.zip
unzip apache-ant-1.10.5-bin.zip
ln -s /opt/apache-ant-1.10.5 /opt/apache-ant
下載最新版本App Engine SDK for Java
cd /opt
wget https://about-10050352.cos.ap-shanghai.myqcloud.com/appengine-java-sdk-1.9.69.zip
unzip appengine-java-sdk-1.9.69.zip
ln -s /opt/appengine-java-sdk-1.9.69 /opt/appengine-java-sdk
設置環境
定位到/etc/profile 目錄
末尾加入
export ANT_HOME=/opt/apache-ant
export JAVA_HOME=/opt/java
export JRE_HOME=/opt/java/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ANT_HOME/bin:/opt/appengine-java-sdk/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
改好應是這樣
示例代碼:/etc/profile
# /etc/profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in /etc/bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom.sh shell script in
# /etc/profile.d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge () {
case ":${PATH}:" in
*:"$1":*)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}
if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=`/usr/bin/id -u`
UID=`/usr/bin/id -ru`
fi
USER="`/usr/bin/id -un`"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi
HOSTNAME=`/usr/bin/hostname 2>/dev/null`
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default, we want umask to get set. This sets it for login shell
# Current threshold for system reserved uid/gids is 200
# You could check uidgid reservation validity in
# /usr/share/doc/setup-*/uidgid file
if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
umask 002
else
umask 022
fi
for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
if [ -r "$i" ]; then
if [ "${-#*i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done
unset i
unset -f pathmunge
export ANT_HOME=/opt/apache-ant
export JAVA_HOME=/opt/java
export JRE_HOME=/opt/java/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ANT_HOME/bin:/opt/appengine-java-sdk/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
執行
source /etc/profile
安裝AppInventor
任務時間:時間未知
30min ~ 60min
下載源碼
cd /opt
git clone https://github.com/mit-cml/appinventor-sources.git
cd appinventor-sources
cp sample-.gitignore .gitignore
git submodule update --init
Ant AppInventor代碼
cd /opt/appinventor-sources/appinventor
ant clean
ant MakeAuthKey
ant
防火牆設置
firewall-cmd --permanent --zone=public --add-port=8888/tcp
firewall-cmd --reload
試運行
看看有沒有出錯代碼,Ctrl+C 退出
dev_appserver.sh --port=8888 --address=0.0.0.0 --disable_update_check /opt/appinventor-sources/appinventor/appengine/build/war
轉移至正式運行目錄
cd /opt
mkdir ai2server
cd ai2server
cp -R /opt/appinventor-sources/appinventor/appengine/build/war ./
cp -R /opt/appinventor-sources/appinventor/buildserver/build/run/lib ./
開機啟動
新建/opt/ai2server/runai2.sh
寫入
示例代碼:/opt/ai2server/runai2.sh
#!/usr/bin/bash
#
#
#
export ANT_HOME=/opt/apache-ant
export JAVA_HOME=/opt/java
export JRE_HOME=/opt/java/jre
export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ANT_HOME/bin:/opt/appengine-java-sdk/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
#pkill -9 java
nohup dev_appserver.sh --port=8888 --address=0.0.0.0 --disable_update_check /opt/ai2server/war/ &> /var/log/ai2d.log &
echo $! > /var/run/ai2d.pid
cd /opt/ai2server/lib
nohup java -Xmx1828m -cp "*" -Dfile.encoding=UTF-8 com.google.appinventor.buildserver.BuildServer --dexCacheDir /tmp/ &> /var/log/ai2b.log &
echo $! > /var/run/ai2b.pid
新建/opt/ai2server/stopai2.sh
寫入
示例代碼:/opt/ai2server/stopai2.sh
#!/usr/bin/bash
#
#
#pkill -9 java
read PID < /var/run/ai2d.pid
kill -15 $PID
read PID < /var/run/ai2b.pid
kill -15 $PID
加權限
chmod +x /opt/ai2server/runai2.sh
chmod +x /opt/ai2server/stopai2.sh
創建service
新建/usr/lib/systemd/system/ai2.service
寫入
示例代碼:/usr/lib/systemd/system/ai2.service
[Unit]
Description=app inventor 2
After=network.target
[Service]
Type=forking
ExecStart=/opt/ai2server/runai2.sh
ExecStop=/opt/ai2server/stopai2.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
啟動
systemctl start ai2.service
systemctl enable ai2.service
AppInventor-Sources更新
cd /opt/appinventor-sources
git pull
git submodule update
cd /opt/appinventor-sources/appinventor
ant clean
ant
/opt/ai2server/stopai2.sh
sleep 10s
cp -Rf /opt/appinventor-sources/appinventor/appengine/build/war /opt/ai2server/
cp -Rf /opt/appinventor-sources/appinventor/buildserver/build/run/lib /opt/ai2server/
/opt/ai2server/runai2.sh