mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-02-08 01:20:07 +08:00
feat: Running environment website adapts to multiple ports (#7805)
This commit is contained in:
parent
d093c0b25b
commit
6744504443
@ -395,8 +395,12 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||
}
|
||||
website.Proxy = proxy
|
||||
}
|
||||
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo:
|
||||
website.Proxy = fmt.Sprintf("127.0.0.1:%s", runtime.Port)
|
||||
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet:
|
||||
proxyPort := runtime.Port
|
||||
if create.Port > 0 {
|
||||
proxyPort = strconv.Itoa(create.Port)
|
||||
}
|
||||
website.Proxy = fmt.Sprintf("127.0.0.1:%s", proxyPort)
|
||||
}
|
||||
case constant.Subsite:
|
||||
parentWebsite, err := websiteRepo.GetFirst(repo.WithByID(create.ParentWebsiteID))
|
||||
@ -450,7 +454,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
|
||||
}
|
||||
|
||||
deleteWebsite := func(t *task.Task) {
|
||||
_ = deleteWebsiteFolder(nginxInstall, website)
|
||||
_ = deleteWebsiteFolder(website)
|
||||
}
|
||||
|
||||
createTask.AddSubTask(i18n.GetMsgByKey("ConfigOpenresty"), configNginx, deleteWebsite)
|
||||
|
@ -225,9 +225,8 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
|
||||
server.UpdateRoot(rootIndex)
|
||||
server.UpdatePHPProxy([]string{website.Proxy}, "")
|
||||
}
|
||||
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo:
|
||||
proxy := fmt.Sprintf("http://127.0.0.1:%d", runtime.Port)
|
||||
server.UpdateRootProxy([]string{proxy})
|
||||
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet:
|
||||
server.UpdateRootProxy([]string{fmt.Sprintf("http://%s", website.Proxy)})
|
||||
}
|
||||
case constant.Subsite:
|
||||
parentWebsite, err := websiteRepo.GetFirst(repo.WithByID(website.ParentWebsiteID))
|
||||
@ -760,14 +759,13 @@ func toMapStr(m map[string]interface{}) map[string]string {
|
||||
return ret
|
||||
}
|
||||
|
||||
func deleteWebsiteFolder(nginxInstall model.AppInstall, website *model.Website) error {
|
||||
nginxFolder := path.Join(global.Dir.AppInstallDir, constant.AppOpenresty, nginxInstall.Name)
|
||||
siteFolder := path.Join(nginxFolder, "www", "sites", website.Alias)
|
||||
func deleteWebsiteFolder(website *model.Website) error {
|
||||
siteFolder := GetSitePath(*website, SiteDir)
|
||||
fileOp := files.NewFileOp()
|
||||
if fileOp.Stat(siteFolder) {
|
||||
_ = fileOp.DeleteDir(siteFolder)
|
||||
}
|
||||
nginxFilePath := path.Join(nginxFolder, "conf", "conf.d", website.PrimaryDomain+".conf")
|
||||
nginxFilePath := GetSitePath(*website, SiteConf)
|
||||
if fileOp.Stat(nginxFilePath) {
|
||||
_ = fileOp.DeleteFile(nginxFilePath)
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export namespace Runtime {
|
||||
version: string;
|
||||
status: string;
|
||||
codeDir: string;
|
||||
port: number;
|
||||
port: string;
|
||||
appID: number;
|
||||
}
|
||||
|
||||
|
@ -2294,6 +2294,8 @@ const message = {
|
||||
changeDatabaseHelper2: 'Switching to another database will cause previous backups to be unrecoverable.',
|
||||
saveCustom: 'Save as Template',
|
||||
rainyun: 'Rain Yun',
|
||||
volcengine: 'Volcengine',
|
||||
runtimePortHelper: 'The current runtime environment has multiple ports. Please select a proxy port.',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Short tag support',
|
||||
|
@ -1883,7 +1883,6 @@ const message = {
|
||||
SSLList: '証明書リスト',
|
||||
createDnsAccount: 'DNSアカウント',
|
||||
aliyun: 'エイリアン',
|
||||
volcengine: 'volcengine',
|
||||
manual: '手動解析',
|
||||
key: '鍵',
|
||||
check: 'ビュー',
|
||||
@ -2156,6 +2155,8 @@ const message = {
|
||||
changeDatabaseHelper2: '別のデータベースに切り替えると、以前のバックアップが復元できなくなる可能性があります。',
|
||||
saveCustom: 'テンプレートとして保存',
|
||||
rainyun: '雨雲',
|
||||
volcengine: 'volcengine',
|
||||
runtimePortHelper: '現在の実行環境には複数のポートがあります。プロキシポートを選択してください。',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短いタグサポート',
|
||||
|
@ -1850,7 +1850,6 @@ const message = {
|
||||
SSLList: '인증서 목록',
|
||||
createDnsAccount: 'DNS 계정 생성',
|
||||
aliyun: '알리윤',
|
||||
volcengine: '볼크엔진',
|
||||
manual: '수동 설정',
|
||||
key: '키',
|
||||
check: '보기',
|
||||
@ -2119,6 +2118,8 @@ const message = {
|
||||
changeDatabaseHelper2: '다른 데이터베이스로 전환하면 이전 백업을 복원할 수 없게 될 수 있습니다.',
|
||||
saveCustom: '템플릿으로 저장',
|
||||
rainyun: 'Rainyun',
|
||||
volcengine: 'volcengine',
|
||||
runtimePortHelper: '현재 실행 환경에 여러 포트가 있습니다. 프록시 포트를 선택하세요.',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '짧은 태그 지원',
|
||||
|
@ -1933,7 +1933,6 @@ const message = {
|
||||
SSLList: 'Senarai Sijil',
|
||||
createDnsAccount: 'Akaun DNS',
|
||||
aliyun: 'Aliyun',
|
||||
volcengine: 'Volcengine',
|
||||
manual: 'Penyelesaian Manual',
|
||||
key: 'Kunci',
|
||||
check: 'Lihat',
|
||||
@ -2208,6 +2207,8 @@ const message = {
|
||||
'Menukar ke pangkalan data lain mungkin menyebabkan sandaran sebelumnya tidak dapat dipulihkan.',
|
||||
saveCustom: 'Simpan sebagai Templat',
|
||||
rainyun: 'Rainyun',
|
||||
volcengine: 'Volcengine',
|
||||
runtimePortHelper: 'Persekitaran runtime semasa mempunyai beberapa port. Sila pilih port proksi.',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Sokongan tag pendek',
|
||||
|
@ -1926,7 +1926,6 @@ const message = {
|
||||
SSLList: 'Lista de certificados',
|
||||
createDnsAccount: 'Conta DNS',
|
||||
aliyun: 'Aliyun',
|
||||
volcengine: 'Volcengine',
|
||||
manual: 'Análise manual',
|
||||
key: 'Chave',
|
||||
check: 'Ver',
|
||||
@ -2204,6 +2203,8 @@ const message = {
|
||||
changeDatabaseHelper2: 'Alternar para outro banco de dados pode tornar backups anteriores irrecuperáveis.',
|
||||
saveCustom: 'Salvar como Modelo',
|
||||
rainyun: 'Rainyun',
|
||||
volcengine: 'Volcengine',
|
||||
runtimePortHelper: 'O ambiente de runtime atual possui várias portas. Por favor, selecione uma porta de proxy.',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Suporte para short tags',
|
||||
|
@ -1925,7 +1925,6 @@ const message = {
|
||||
SSLList: 'Список сертификатов',
|
||||
createDnsAccount: 'DNS аккаунт',
|
||||
aliyun: 'Aliyun',
|
||||
volcengine: 'Volcengine',
|
||||
manual: 'Ручная настройка',
|
||||
key: 'Ключ',
|
||||
check: 'Просмотр',
|
||||
@ -2204,6 +2203,8 @@ const message = {
|
||||
'Переключение на другую базу данных может сделать предыдущие резервные копии невосстановимыми.',
|
||||
saveCustom: 'Сохранить как Шаблон',
|
||||
rainyun: 'Rainyun',
|
||||
volcengine: 'Volcengine',
|
||||
runtimePortHelper: 'O ambiente de runtime atual possui várias portas. Por favor, selecione uma porta de proxy.',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: 'Поддержка коротких тегов',
|
||||
|
@ -2132,6 +2132,8 @@ const message = {
|
||||
changeDatabaseHelper2: '切換其他資料庫會導致以前的備份無法恢復。',
|
||||
saveCustom: '另存为模版',
|
||||
rainyun: '雨雲',
|
||||
volcengine: 'Volcengine',
|
||||
runtimePortHelper: '當前運行環境存在多個端口,請選擇一個代理端口。',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短標簽支持',
|
||||
|
@ -2114,6 +2114,7 @@ const message = {
|
||||
saveCustom: '另存为模版',
|
||||
rainyun: '雨云',
|
||||
volcengine: '火山引擎',
|
||||
runtimePortHelper: '当前运行环境存在多个端口,请选择一个代理端口',
|
||||
},
|
||||
php: {
|
||||
short_open_tag: '短标签支持',
|
||||
|
@ -685,3 +685,13 @@ export const escapeProxyURL = (url: string): string => {
|
||||
|
||||
return url.replace(/[\/:?#[\]@!$&'()*+,;=%~]/g, (match) => encodeMap[match] || match);
|
||||
};
|
||||
|
||||
export function getRuntimeLabel(type: string) {
|
||||
if (type == 'appstore') {
|
||||
return i18n.global.t('menu.apps');
|
||||
}
|
||||
if (type == 'local') {
|
||||
return i18n.global.t('commons.table.local');
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
@ -208,7 +208,7 @@
|
||||
<el-option
|
||||
v-for="run in runtimes"
|
||||
:key="run.name"
|
||||
:label="run.name + ' [' + $t('runtime.' + run.resource) + ']'"
|
||||
:label="run.name + ' [' + getRuntimeLabel(run.resource) + ']'"
|
||||
:value="run.id"
|
||||
>
|
||||
<el-row>
|
||||
@ -218,7 +218,7 @@
|
||||
</span>
|
||||
</el-col>
|
||||
<el-col :span="10">
|
||||
{{ ' [' + $t('runtime.' + run.resource) + ']' }}
|
||||
{{ ' [' + getRuntimeLabel(run.resource) + ']' }}
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-option>
|
||||
@ -237,6 +237,21 @@
|
||||
<el-input v-model.number="website.port"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item
|
||||
:label="$t('setting.proxyPort')"
|
||||
prop="port"
|
||||
v-if="website.runtimeType !== 'php' && runtimePorts.length > 0"
|
||||
>
|
||||
<el-select v-model="website.port">
|
||||
<el-option
|
||||
v-for="(port, index) in runtimePorts"
|
||||
:key="index"
|
||||
:label="port"
|
||||
:value="port"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<span class="input-help">{{ $t('website.runtimePortHelper') }}</span>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item prop="advanced" v-if="website.type === 'deployment' && website.appType === 'new'">
|
||||
<el-checkbox v-model="website.appinstall.advanced" :label="$t('app.advanced')" size="large" />
|
||||
@ -495,12 +510,10 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<span>
|
||||
<el-button @click="handleClose" :disabled="loading">{{ $t('commons.button.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="submit(websiteForm)" :disabled="loading">
|
||||
{{ $t('commons.button.confirm') }}
|
||||
</el-button>
|
||||
</span>
|
||||
</template>
|
||||
<Check ref="preCheckRef"></Check>
|
||||
<el-card width="30%" v-if="!versionExist" class="mask-prompt">
|
||||
@ -514,7 +527,7 @@
|
||||
|
||||
<script lang="ts" setup name="CreateWebSite">
|
||||
import { App } from '@/api/interface/app';
|
||||
import { getAppByKey, getAppDetail, searchApp, getAppInstalled, getAppDetailByID } from '@/api/modules/app';
|
||||
import { getAppByKey, getAppDetail, searchApp, getAppInstalled } from '@/api/modules/app';
|
||||
import {
|
||||
createWebsite,
|
||||
getWebsiteOptions,
|
||||
@ -534,7 +547,7 @@ import { getGroupList } from '@/api/modules/group';
|
||||
import { Group } from '@/api/interface/group';
|
||||
import { SearchRuntimes } from '@/api/modules/runtime';
|
||||
import { Runtime } from '@/api/interface/runtime';
|
||||
import { getRandomStr } from '@/utils/util';
|
||||
import { getRandomStr, getRuntimeLabel } from '@/utils/util';
|
||||
import TaskLog from '@/components/task-log/index.vue';
|
||||
import { getAppService } from '@/api/modules/app';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
@ -575,7 +588,7 @@ const initData = () => ({
|
||||
ftpUser: '',
|
||||
ftpPassword: '',
|
||||
proxyType: 'tcp',
|
||||
port: 9000,
|
||||
port: 0,
|
||||
proxyProtocol: 'http://',
|
||||
proxyAddress: '',
|
||||
runtimeType: 'php',
|
||||
@ -644,12 +657,13 @@ const paramKey = ref(1);
|
||||
const preCheckRef = ref();
|
||||
const staticPath = ref('');
|
||||
const runtimeResource = ref('appstore');
|
||||
const runtimeReq = ref<Runtime.RuntimeReq>({
|
||||
const initRuntimeReq = () => ({
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
status: 'running',
|
||||
type: 'php',
|
||||
});
|
||||
const runtimeReq = ref<Runtime.RuntimeReq>(initRuntimeReq());
|
||||
const runtimes = ref<Runtime.RuntimeDTO[]>([]);
|
||||
const versionExist = ref(true);
|
||||
const em = defineEmits(['close']);
|
||||
@ -659,6 +673,7 @@ const ssls = ref();
|
||||
const websiteSSL = ref();
|
||||
const parentWebsites = ref();
|
||||
const dirs = ref([]);
|
||||
const runtimePorts = ref([]);
|
||||
|
||||
const handleClose = () => {
|
||||
open.value = false;
|
||||
@ -763,15 +778,6 @@ const getDetail = (version: string) => {
|
||||
});
|
||||
};
|
||||
|
||||
const getDetailByID = (id: number) => {
|
||||
getAppDetailByID(id).then((res) => {
|
||||
website.value.appinstall.appDetailId = res.data.id;
|
||||
appDetail.value = res.data;
|
||||
appParams.value = res.data.params;
|
||||
paramKey.value++;
|
||||
});
|
||||
};
|
||||
|
||||
const changeRuntimeType = () => {
|
||||
runtimeReq.value.type = website.value.runtimeType;
|
||||
website.value.appinstall.advanced = false;
|
||||
@ -783,8 +789,11 @@ const changeRuntime = (runID: number) => {
|
||||
runtimes.value.forEach((item) => {
|
||||
if (item.id === runID) {
|
||||
runtimeResource.value = item.resource;
|
||||
if (item.resource === 'appstore') {
|
||||
getDetailByID(item.appDetailID);
|
||||
runtimePorts.value = item.port.split(',').map((port: string) => parseInt(port.trim(), 10));
|
||||
if (runtimePorts.value.length > 1) {
|
||||
website.value.port = runtimePorts.value[0];
|
||||
} else {
|
||||
website.value.port = 0;
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -792,15 +801,18 @@ const changeRuntime = (runID: number) => {
|
||||
|
||||
const getRuntimes = async () => {
|
||||
try {
|
||||
console.log(runtimeReq.value);
|
||||
const res = await SearchRuntimes(runtimeReq.value);
|
||||
runtimes.value = res.data.items || [];
|
||||
if (runtimes.value.length > 0) {
|
||||
const first = runtimes.value[0];
|
||||
website.value.runtimeID = first.id;
|
||||
console.log('runtimeID', first.id);
|
||||
runtimeResource.value = first.resource;
|
||||
if (first.resource === 'appstore') {
|
||||
getDetailByID(first.appDetailID);
|
||||
runtimePorts.value = first.port.split(',').map((port: string) => parseInt(port.trim(), 10));
|
||||
if (runtimePorts.value.length > 1) {
|
||||
website.value.port = runtimePorts.value[0];
|
||||
} else {
|
||||
website.value.port = 0;
|
||||
}
|
||||
}
|
||||
} catch (error) {}
|
||||
@ -818,11 +830,14 @@ const acceptParams = async (installPath: string) => {
|
||||
website.value.webSiteGroupId = res.data[0].id;
|
||||
website.value.type = 'deployment';
|
||||
runtimeResource.value = 'appstore';
|
||||
runtimeReq.value = initRuntimeReq();
|
||||
|
||||
searchAppInstalled('website');
|
||||
listAcmeAccount();
|
||||
|
||||
open.value = true;
|
||||
|
||||
console.log('runtimeID', website.value.runtimeID);
|
||||
};
|
||||
|
||||
const changeAppType = (type: string) => {
|
||||
|
@ -84,7 +84,7 @@
|
||||
{{ row.primaryDomain }}
|
||||
</el-text>
|
||||
<el-popover
|
||||
placement="left"
|
||||
placement="right"
|
||||
trigger="hover"
|
||||
:width="300"
|
||||
@before-enter="searchDomains(row.id)"
|
||||
@ -548,9 +548,6 @@ const getUrl = (domain: Website.Domain, website: Website.Website): string => {
|
||||
return url;
|
||||
};
|
||||
|
||||
onBeforeMount(() => {
|
||||
console.log('1111');
|
||||
}),
|
||||
onMounted(() => {
|
||||
search();
|
||||
listGroup();
|
||||
|
Loading…
x
Reference in New Issue
Block a user