mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
加入php安装
This commit is contained in:
@@ -20,6 +20,7 @@ type Lang struct {
|
||||
ExecutablePaths []string `json:"executable_paths"`
|
||||
DepExecutablePath string `json:"dep_executable_path"`
|
||||
LockPath string `json:"lock_path"`
|
||||
InstallScript string `json:"install_script"`
|
||||
InstallStatus string `json:"install_status"`
|
||||
}
|
||||
|
||||
|
||||
19
backend/scripts/install-dotnet.sh
Executable file
19
backend/scripts/install-dotnet.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
# lock global
|
||||
touch /tmp/install.lock
|
||||
|
||||
# lock
|
||||
touch /tmp/install-dotnet.lock
|
||||
|
||||
apt-get install curl
|
||||
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
|
||||
mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
|
||||
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-artful-prod artful main" > /etc/apt/sources.list.d/dotnetdev.list'
|
||||
apt-get install apt-transport-https
|
||||
apt-get update
|
||||
apt-get install dotnet-sdk-2.1
|
||||
|
||||
# unlock global
|
||||
rm /tmp/install.lock
|
||||
|
||||
# unlock
|
||||
rm /tmp/install-dotnet.lock
|
||||
13
backend/scripts/install-php.sh
Executable file
13
backend/scripts/install-php.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
# lock global
|
||||
touch /tmp/install.lock
|
||||
|
||||
# lock
|
||||
touch /tmp/install-php.lock
|
||||
|
||||
apt-get install php
|
||||
|
||||
# unlock global
|
||||
rm /tmp/install.lock
|
||||
|
||||
# unlock
|
||||
rm /tmp/install-php.lock
|
||||
@@ -15,3 +15,11 @@ then
|
||||
/bin/sh /app/backend/scripts/install-java.sh
|
||||
echo "installed java"
|
||||
fi
|
||||
|
||||
# install dotnet
|
||||
if [ "${CRAWLAB_SERVER_LANG_DOTNET}" = "Y" ];
|
||||
then
|
||||
echo "installing dotnet"
|
||||
/bin/sh /app/backend/scripts/install-dotnet.sh
|
||||
echo "installed dotnet"
|
||||
fi
|
||||
|
||||
@@ -39,45 +39,19 @@ func (s *InstallLangService) ClientHandle() (o interface{}, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// 本地安装Node.js
|
||||
func InstallNodejsLocalLang() (string, error) {
|
||||
cmd := exec.Command("/bin/sh", path.Join("scripts", "install-nodejs.sh"))
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
debug.PrintStack()
|
||||
return string(output), err
|
||||
}
|
||||
|
||||
// TODO: check if Node.js is installed successfully
|
||||
|
||||
return string(output), nil
|
||||
}
|
||||
|
||||
// 本地安装Java
|
||||
func InstallJavaLocalLang() (string, error) {
|
||||
cmd := exec.Command("/bin/sh", path.Join("scripts", "install-java.sh"))
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
debug.PrintStack()
|
||||
return string(output), err
|
||||
}
|
||||
|
||||
// TODO: check if Java is installed successfully
|
||||
|
||||
return string(output), nil
|
||||
}
|
||||
|
||||
// 本地安装语言
|
||||
func InstallLangLocal(lang string) (o string, err error) {
|
||||
if lang == constants.Nodejs {
|
||||
o, err = InstallNodejsLocalLang()
|
||||
} else if lang == constants.Java {
|
||||
o, err = InstallNodejsLocalLang()
|
||||
} else {
|
||||
l := utils.GetLangFromLangNamePlain(lang)
|
||||
if l.Name == "" || l.InstallScript == "" {
|
||||
return "", errors.New(fmt.Sprintf("%s is not implemented", lang))
|
||||
}
|
||||
cmd := exec.Command("/bin/sh", path.Join("scripts", l.InstallScript))
|
||||
output, err := cmd.Output()
|
||||
if err != nil {
|
||||
log.Error(err.Error())
|
||||
debug.PrintStack()
|
||||
return string(output), err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,28 @@ func GetLangList() []entity.Lang {
|
||||
ExecutablePaths: []string{"/usr/bin/node", "/usr/local/bin/node"},
|
||||
DepExecutablePath: "/usr/local/bin/npm",
|
||||
LockPath: "/tmp/install-nodejs.lock",
|
||||
InstallScript: "install-nodejs.sh",
|
||||
},
|
||||
{
|
||||
Name: "Java",
|
||||
ExecutableName: "java",
|
||||
ExecutablePaths: []string{"/usr/bin/java", "/usr/local/bin/java"},
|
||||
LockPath: "/tmp/install-java.lock",
|
||||
InstallScript: "install-java.sh",
|
||||
},
|
||||
{
|
||||
Name: ".Net Core",
|
||||
ExecutableName: "dotnet",
|
||||
ExecutablePaths: []string{"/usr/bin/dotnet", "/usr/local/bin/dotnet"},
|
||||
LockPath: "/tmp/install-dotnet.lock",
|
||||
InstallScript: "install-dotnet.sh",
|
||||
},
|
||||
{
|
||||
Name: "PHP",
|
||||
ExecutableName: "php",
|
||||
ExecutablePaths: []string{"/usr/bin/php", "/usr/local/bin/php"},
|
||||
LockPath: "/tmp/install-php.lock",
|
||||
InstallScript: "install-php.sh",
|
||||
},
|
||||
}
|
||||
return list
|
||||
|
||||
@@ -43,7 +43,9 @@ spec:
|
||||
- name: CRAWLAB_SERVER_LANG_NODE
|
||||
value: "N"
|
||||
- name: CRAWLAB_SERVER_LANG_JAVA
|
||||
value: "Y"
|
||||
value: "N"
|
||||
- name: CRAWLAB_SERVER_LANG_DOTNET
|
||||
value: "N"
|
||||
- name: CRAWLAB_SERVER_REGISTER_TYPE
|
||||
value: "hostname"
|
||||
ports:
|
||||
|
||||
@@ -28,6 +28,8 @@ spec:
|
||||
- name: CRAWLAB_SERVER_LANG_NODE
|
||||
value: "N"
|
||||
- name: CRAWLAB_SERVER_LANG_JAVA
|
||||
value: "Y"
|
||||
value: "N"
|
||||
- name: CRAWLAB_SERVER_LANG_DOTNET
|
||||
value: "N"
|
||||
- name: CRAWLAB_SERVER_REGISTER_TYPE
|
||||
value: "hostname"
|
||||
|
||||
@@ -1,87 +1,96 @@
|
||||
<template>
|
||||
<div class="node-installation-matrix">
|
||||
<div class="lang-table">
|
||||
<el-table
|
||||
class="table"
|
||||
:data="nodeList"
|
||||
:header-cell-style="{background:'rgb(48, 65, 86)',color:'white',height:'50px'}"
|
||||
border
|
||||
@row-click="onLangTableRowClick"
|
||||
>
|
||||
<el-table-column
|
||||
:label="$t('Node')"
|
||||
width="240px"
|
||||
prop="name"
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('nodeList.type')"
|
||||
width="120px"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="primary" v-if="scope.row.is_master">{{$t('Master')}}</el-tag>
|
||||
<el-tag type="warning" v-else>{{$t('Worker')}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('Status')"
|
||||
width="120px"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="info" v-if="scope.row.status === 'offline'">{{$t('Offline')}}</el-tag>
|
||||
<el-tag type="success" v-else-if="scope.row.status === 'online'">{{$t('Online')}}</el-tag>
|
||||
<el-tag type="danger" v-else>{{$t('Unavailable')}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-for="l in langs"
|
||||
:key="l.name"
|
||||
:label="l.label"
|
||||
width="220px"
|
||||
>
|
||||
<template slot="header" slot-scope="scope">
|
||||
<div class="header-with-action">
|
||||
<span>{{scope.column.label}}</span>
|
||||
<el-button type="primary" size="mini" @click="onInstallAll(scope.column.label)">
|
||||
{{$t('Install')}}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<template v-if="getLangInstallStatus(scope.row._id, l.name) === 'installed'">
|
||||
<el-tag type="success">
|
||||
<i class="el-icon-check"></i>
|
||||
{{$t('Installed')}}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template v-else-if="getLangInstallStatus(scope.row._id, l.name) === 'installing'">
|
||||
<el-tag type="warning">
|
||||
<i class="el-icon-loading"></i>
|
||||
{{$t('Installing')}}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template
|
||||
v-else-if="['installing-other', 'not-installed'].includes(getLangInstallStatus(scope.row._id, l.name))"
|
||||
<el-tabs v-model="activeTabName">
|
||||
<el-tab-pane :label="$t('Languages')" name="lang">
|
||||
<div class="lang-table">
|
||||
<el-table
|
||||
class="table"
|
||||
:data="nodeList"
|
||||
:header-cell-style="{background:'rgb(48, 65, 86)',color:'white',height:'50px'}"
|
||||
border
|
||||
@row-click="onLangTableRowClick"
|
||||
>
|
||||
<el-table-column
|
||||
:label="$t('Node')"
|
||||
width="240px"
|
||||
prop="name"
|
||||
fixed
|
||||
/>
|
||||
<el-table-column
|
||||
:label="$t('nodeList.type')"
|
||||
width="120px"
|
||||
fixed
|
||||
>
|
||||
<div class="cell-with-action">
|
||||
<el-tag type="danger">
|
||||
<i class="el-icon-error"></i>
|
||||
{{$t('Not Installed')}}
|
||||
</el-tag>
|
||||
<el-button type="primary" size="mini" @click="onInstall(scope.row._id, scope.column.label, $event)">
|
||||
{{$t('Install')}}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="getLangInstallStatus(scope.row._id, l.name) === 'na'">
|
||||
<el-tag type="info">
|
||||
<i class="el-icon-question"></i>
|
||||
{{$t('N/A')}}
|
||||
</el-tag>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="primary" v-if="scope.row.is_master">{{$t('Master')}}</el-tag>
|
||||
<el-tag type="warning" v-else>{{$t('Worker')}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('Status')"
|
||||
width="120px"
|
||||
fixed
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-tag type="info" v-if="scope.row.status === 'offline'">{{$t('Offline')}}</el-tag>
|
||||
<el-tag type="success" v-else-if="scope.row.status === 'online'">{{$t('Online')}}</el-tag>
|
||||
<el-tag type="danger" v-else>{{$t('Unavailable')}}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
v-for="l in langs"
|
||||
:key="l.name"
|
||||
:label="l.label"
|
||||
width="220px"
|
||||
>
|
||||
<template slot="header" slot-scope="scope">
|
||||
<div class="header-with-action">
|
||||
<span>{{scope.column.label}}</span>
|
||||
<el-button type="primary" size="mini" @click="onInstallAll(scope.column.label)">
|
||||
{{$t('Install')}}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<template v-if="getLangInstallStatus(scope.row._id, l.name) === 'installed'">
|
||||
<el-tag type="success">
|
||||
<i class="el-icon-check"></i>
|
||||
{{$t('Installed')}}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template v-else-if="getLangInstallStatus(scope.row._id, l.name) === 'installing'">
|
||||
<el-tag type="warning">
|
||||
<i class="el-icon-loading"></i>
|
||||
{{$t('Installing')}}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template
|
||||
v-else-if="['installing-other', 'not-installed'].includes(getLangInstallStatus(scope.row._id, l.name))"
|
||||
>
|
||||
<div class="cell-with-action">
|
||||
<el-tag type="danger">
|
||||
<i class="el-icon-error"></i>
|
||||
{{$t('Not Installed')}}
|
||||
</el-tag>
|
||||
<el-button type="primary" size="mini" @click="onInstall(scope.row._id, scope.column.label, $event)">
|
||||
{{$t('Install')}}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
<template v-else-if="getLangInstallStatus(scope.row._id, l.name) === 'na'">
|
||||
<el-tag type="info">
|
||||
<i class="el-icon-question"></i>
|
||||
{{$t('N/A')}}
|
||||
</el-tag>
|
||||
</template>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane :label="$t('Dependencies')" name="dep">
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -101,10 +110,13 @@ export default {
|
||||
langs: [
|
||||
{ label: 'Python', name: 'python' },
|
||||
{ label: 'Node.js', name: 'node' },
|
||||
{ label: 'Java', name: 'java' }
|
||||
{ label: 'Java', name: 'java' },
|
||||
{ label: '.Net Core', name: 'dotnet' },
|
||||
{ label: 'PHP', name: 'php' }
|
||||
],
|
||||
dataDict: {},
|
||||
handle: undefined
|
||||
handle: undefined,
|
||||
activeTabName: 'lang'
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
||||
Reference in New Issue
Block a user