加入php安装

This commit is contained in:
marvzhang
2020-03-10 16:42:40 +08:00
parent 689d44bbe7
commit 96ae068528
9 changed files with 167 additions and 120 deletions

View File

@@ -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"`
}

View 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
View 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

View File

@@ -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

View File

@@ -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
}

View File

@@ -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

View File

@@ -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:

View File

@@ -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"

View File

@@ -1,5 +1,7 @@
<template>
<div class="node-installation-matrix">
<el-tabs v-model="activeTabName">
<el-tab-pane :label="$t('Languages')" name="lang">
<div class="lang-table">
<el-table
class="table"
@@ -12,10 +14,12 @@
:label="$t('Node')"
width="240px"
prop="name"
fixed
/>
<el-table-column
:label="$t('nodeList.type')"
width="120px"
fixed
>
<template slot-scope="scope">
<el-tag type="primary" v-if="scope.row.is_master">{{$t('Master')}}</el-tag>
@@ -25,6 +29,7 @@
<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>
@@ -82,6 +87,10 @@
</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: {