added java env

This commit is contained in:
marvzhang
2020-03-04 10:36:58 +08:00
parent 97c0aaf2d1
commit 89d1846510
9 changed files with 65 additions and 12 deletions

View File

@@ -15,11 +15,11 @@ type Executable struct {
}
type Lang struct {
Name string `json:"name"`
ExecutableName string `json:"executable_name"`
ExecutablePath string `json:"executable_path"`
DepExecutablePath string `json:"dep_executable_path"`
Installed bool `json:"installed"`
Name string `json:"name"`
ExecutableName string `json:"executable_name"`
ExecutablePaths []string `json:"executable_paths"`
DepExecutablePath string `json:"dep_executable_path"`
Installed bool `json:"installed"`
}
type Dependency struct {

View File

@@ -0,0 +1,11 @@
#!/bin/env bash
# lock
touch /tmp/install-java.lock
# install java
apt-get install -y default-jdk
ln -s /usr/bin/java /usr/local/bin/java
# unlock
rm /tmp/install-java.lock

View File

@@ -1,5 +1,8 @@
#!/bin/env bash
# lock
touch /tmp/install-nodejs.lock
# install nvm
BASE_DIR=`dirname $0`
/bin/bash ${BASE_DIR}/install-nvm.sh
@@ -33,3 +36,6 @@ apt-get update && apt-get install -y --no-install-recommends gconf-service libas
PUPPETEER_DOWNLOAD_HOST=https://npm.taobao.org/mirrors
npm config set puppeteer_download_host=https://npm.taobao.org/mirrors
npm install puppeteer-chromium-resolver crawlab-sdk -g --unsafe-perm=true --registry=https://registry.npm.taobao.org
# unlock
rm /tmp/install-nodejs.lock

View File

@@ -65,9 +65,9 @@ func GetSystemInfo(nodeId string) (sysInfo entity.SystemInfo, err error) {
// 获取语言列表
func GetLangList(nodeId string) []entity.Lang {
list := []entity.Lang{
{Name: "Python", ExecutableName: "python", ExecutablePath: "/usr/local/bin/python", DepExecutablePath: "/usr/local/bin/pip"},
{Name: "Node.js", ExecutableName: "node", ExecutablePath: "/usr/local/bin/node", DepExecutablePath: "/usr/local/bin/npm"},
//{Name: "Java", ExecutableName: "java", ExecutablePath: "/usr/local/bin/java"},
{Name: "Python", ExecutableName: "python", ExecutablePaths: []string{"/usr/bin/python", "/usr/local/bin/python"}, DepExecutablePath: "/usr/local/bin/pip"},
{Name: "Node.js", ExecutableName: "node", ExecutablePaths: []string{"/usr/bin/node", "/usr/local/bin/node"}, DepExecutablePath: "/usr/local/bin/npm"},
{Name: "Java", ExecutableName: "java", ExecutablePaths: []string{"/usr/bin/java", "/usr/local/bin/java"}},
}
for i, lang := range list {
list[i].Installed = IsInstalledLang(nodeId, lang)
@@ -93,8 +93,10 @@ func IsInstalledLang(nodeId string, lang entity.Lang) bool {
return false
}
for _, exec := range sysInfo.Executables {
if exec.Path == lang.ExecutablePath {
return true
for _, path := range lang.ExecutablePaths {
if exec.Path == path {
return true
}
}
}
return false

View File

@@ -23,6 +23,7 @@ services:
# CRAWLAB_SERVER_REGISTER_IP: "127.0.0.1" # node register ip 节点注册IP. 节点唯一识别号只有当 CRAWLAB_SERVER_REGISTER_TYPE "ip" 时才生效
# CRAWLAB_TASK_WORKERS: 4 # number of task executors 任务执行器个数并行执行任务数
# CRAWLAB_SERVER_LANG_NODE: "Y" # whether to pre-install Node.js 预安装 Node.js 语言环境
# CRAWLAB_SERVER_LANG_JAVA: "Y" # whether to pre-install Java 预安装 Java 语言环境
# CRAWLAB_SETTING_ALLOWREGISTER: "N" # whether to allow user registration 是否允许用户注册
# CRAWLAB_SETTING_ENABLETUTORIAL: "N" # whether to enable tutorial 是否启用教程
# CRAWLAB_NOTIFICATION_MAIL_SERVER: smtp.exmaple.com # STMP server address STMP 服务器地址

View File

@@ -26,7 +26,14 @@ service nginx start
if [ "${CRAWLAB_SERVER_LANG_NODE}" = "Y" ];
then
echo "installing node.js"
/bin/sh /app/backend/scripts/install-nodejs.sh
/bin/sh /app/backend/scripts/install-nodejs.sh &
fi
# install languages: Java
if [ "${CRAWLAB_SERVER_LANG_JAVA}" = "Y" ];
then
echo "installing java"
/bin/sh /app/backend/scripts/install-java.sh &
fi
# generate ssh

View File

@@ -152,6 +152,7 @@ export default {
methods: {
async getDepList () {
this.loading = true
this.depList = []
const res = await this.$request.get(`/nodes/${this.nodeForm._id}/deps`, {
lang: this.activeLang.executable_name,
dep_name: this.depName
@@ -175,6 +176,7 @@ export default {
},
async getInstalledDepList () {
this.loading = true
this.installedDepList = []
const res = await this.$request.get(`/nodes/${this.nodeForm._id}/deps/installed`, {
lang: this.activeLang.executable_name
})

View File

@@ -0,0 +1,20 @@
<template>
<div class="node-installation-matrix">
</div>
</template>
<script>
export default {
name: 'NodeInstallationMatrix',
props: {
activeTab: {
type: String,
default: ''
}
}
}
</script>
<style scoped>
</style>

View File

@@ -142,6 +142,9 @@
<el-tab-pane :label="$t('Network')">
<node-network :active-tab="activeTab"/>
</el-tab-pane>
<el-tab-pane :label="$t('Installation')">
<node-installation-matrix :active-tab="activeTab"/>
</el-tab-pane>
</el-tabs>
</div>
</template>
@@ -153,10 +156,11 @@ import {
} from 'vuex'
import 'github-markdown-css/github-markdown.css'
import NodeNetwork from '../../components/Node/NodeNetwork'
import NodeInstallationMatrix from '../../components/Node/NodeInstallationMatrix'
export default {
name: 'NodeList',
components: { NodeNetwork },
components: { NodeInstallationMatrix, NodeNetwork },
data () {
return {
pagination: {