From 27fd16f345bc981c20978a5948a9907d650aa428 Mon Sep 17 00:00:00 2001 From: marvzhang Date: Thu, 30 Jul 2020 11:12:36 +0800 Subject: [PATCH] added golang --- backend/conf/config.yml | 2 +- backend/scripts/install-go.sh | 20 +++++++++++++++++++ backend/scripts/install-nodejs.sh | 16 ++++++++++++--- backend/scripts/install.sh | 16 +++++++++++++++ backend/utils/system.go | 7 +++++++ docker-compose.yml | 1 + docker_init.sh | 2 +- .../Node/NodeInstallationMatrix.vue | 3 ++- 8 files changed, 61 insertions(+), 6 deletions(-) create mode 100644 backend/scripts/install-go.sh diff --git a/backend/conf/config.yml b/backend/conf/config.yml index cfb74881..9a38fa70 100644 --- a/backend/conf/config.yml +++ b/backend/conf/config.yml @@ -39,7 +39,7 @@ task: workers: 16 other: tmppath: "/tmp" -version: 0.5.0 +version: 0.5.1 setting: crawlabLogToES: "N" # Send crawlab runtime log to ES, open this option "Y", remember to set esClient crawlabLogIndex: "crawlab-log" diff --git a/backend/scripts/install-go.sh b/backend/scripts/install-go.sh new file mode 100644 index 00000000..d825499b --- /dev/null +++ b/backend/scripts/install-go.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# lock global +touch /tmp/install.lock + +# lock +touch /tmp/install-go.lock + +# install golang +apt-get update +apt-get install -y golang + +# environment variables +export GOPROXY=https://goproxy.cn +export GOPATH=/opt/go + +# unlock global +rm /tmp/install.lock + +# unlock +rm /tmp/install-go.lock \ No newline at end of file diff --git a/backend/scripts/install-nodejs.sh b/backend/scripts/install-nodejs.sh index c1778b01..37b07c27 100644 --- a/backend/scripts/install-nodejs.sh +++ b/backend/scripts/install-nodejs.sh @@ -8,8 +8,8 @@ touch /tmp/install-nodejs.lock # install node.js curl -sL https://deb.nodesource.com/setup_10.x | bash - -apt install -y nodejs -apt install -y npm +apt-get update && apt install -y nodejs nodejs-dev node-gyp libssl1.0-dev +apt-get update && apt install -y npm # install chromium # See https://crbug.com/795759 @@ -20,7 +20,17 @@ apt-get update && apt-get install -yq libgconf-2-4 # Note: this installs the necessary libs to make the bundled version # of Chromium that Puppeteer # installs, work. -apt-get update && apt-get install -y --no-install-recommends gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget +RUN apt-get update \ + && apt-get install -y wget gnupg \ + && wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \ + && sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' \ + && apt-get update \ + && apt-get -y install xvfb gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 \ + libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \ + libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 \ + libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \ + libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget \ + && rm -rf /var/lib/apt/lists/* # install default dependencies PUPPETEER_DOWNLOAD_HOST=https://npm.taobao.org/mirrors diff --git a/backend/scripts/install.sh b/backend/scripts/install.sh index fe89d1b2..6173528d 100644 --- a/backend/scripts/install.sh +++ b/backend/scripts/install.sh @@ -23,3 +23,19 @@ then /bin/sh /app/backend/scripts/install-dotnet.sh echo "installed dotnet" fi + +# install php +if [ "${CRAWLAB_SERVER_LANG_PHP}" = "Y" ]; +then + echo "installing php" + /bin/sh /app/backend/scripts/install-php.sh + echo "installed php" +fi + +# install go +if [ "${CRAWLAB_SERVER_LANG_GO}" = "Y" ]; +then + echo "installing go" + /bin/sh /app/backend/scripts/install-go.sh + echo "installed go" +fi diff --git a/backend/utils/system.go b/backend/utils/system.go index 5721aadf..0fbc3776 100644 --- a/backend/utils/system.go +++ b/backend/utils/system.go @@ -50,6 +50,13 @@ func GetLangList() []entity.Lang { LockPath: "/tmp/install-php.lock", InstallScript: "install-php.sh", }, + { + Name: "Golang", + ExecutableName: "go", + ExecutablePaths: []string{"/usr/bin/go", "/usr/local/bin/go"}, + LockPath: "/tmp/install-go.lock", + InstallScript: "install-go.sh", + }, } return list } diff --git a/docker-compose.yml b/docker-compose.yml index f82c33c7..1c06f422 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -26,6 +26,7 @@ services: # CRAWLAB_SERVER_LANG_JAVA: "Y" # whether to pre-install Java 预安装 Java 语言环境 # CRAWLAB_SERVER_LANG_DOTNET: "Y" # whether to pre-install .Net core 预安装 .Net Core 语言环境 # CRAWLAB_SERVER_LANG_PHP: "Y" # whether to pre-install PHP 预安装 PHP 语言环境 + # CRAWLAB_SERVER_LANG_GO: "Y" # whether to pre-install Golang 预安装 Golang 语言环境 # CRAWLAB_SETTING_ALLOWREGISTER: "N" # whether to allow user registration 是否允许用户注册 # CRAWLAB_SETTING_ENABLETUTORIAL: "N" # whether to enable tutorial 是否启用教程 # CRAWLAB_SETTING_RUNONMASTER: "N" # whether to run on master node 是否在主节点上运行任务 diff --git a/docker_init.sh b/docker_init.sh index dce1137a..dfef4eaf 100755 --- a/docker_init.sh +++ b/docker_init.sh @@ -23,7 +23,7 @@ fi service nginx start # install languages -if [ "${CRAWLAB_SERVER_LANG_NODE}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_JAVA}" = "Y" ]; +if [ "${CRAWLAB_SERVER_LANG_NODE}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_JAVA}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_DOTNET}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_PHP}" = "Y" ] || [ "${CRAWLAB_SERVER_LANG_GO}" = "Y" ]; then echo "installing languages" echo "you can view log at /var/log/install.sh.log" diff --git a/frontend/src/components/Node/NodeInstallationMatrix.vue b/frontend/src/components/Node/NodeInstallationMatrix.vue index 25d4a331..973a7874 100644 --- a/frontend/src/components/Node/NodeInstallationMatrix.vue +++ b/frontend/src/components/Node/NodeInstallationMatrix.vue @@ -225,7 +225,8 @@ { label: 'Node.js', name: 'node', hasDeps: true }, { label: 'Java', name: 'java', hasDeps: false }, { label: '.Net Core', name: 'dotnet', hasDeps: false }, - { label: 'PHP', name: 'php', hasDeps: false } + { label: 'PHP', name: 'php', hasDeps: false }, + { label: 'Golang', name: 'go', hasDeps: false } ], langsDataDict: {}, handle: undefined,