Skip to content

Commit 6744504

Browse files
feat: Running environment website adapts to multiple ports (#7805)
1 parent d093c0b commit 6744504

File tree

14 files changed

+84
-50
lines changed

14 files changed

+84
-50
lines changed

agent/app/service/website.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,12 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
395395
}
396396
website.Proxy = proxy
397397
}
398-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo:
399-
website.Proxy = fmt.Sprintf("127.0.0.1:%s", runtime.Port)
398+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet:
399+
proxyPort := runtime.Port
400+
if create.Port > 0 {
401+
proxyPort = strconv.Itoa(create.Port)
402+
}
403+
website.Proxy = fmt.Sprintf("127.0.0.1:%s", proxyPort)
400404
}
401405
case constant.Subsite:
402406
parentWebsite, err := websiteRepo.GetFirst(repo.WithByID(create.ParentWebsiteID))
@@ -450,7 +454,7 @@ func (w WebsiteService) CreateWebsite(create request.WebsiteCreate) (err error)
450454
}
451455

452456
deleteWebsite := func(t *task.Task) {
453-
_ = deleteWebsiteFolder(nginxInstall, website)
457+
_ = deleteWebsiteFolder(website)
454458
}
455459

456460
createTask.AddSubTask(i18n.GetMsgByKey("ConfigOpenresty"), configNginx, deleteWebsite)

agent/app/service/website_utils.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,8 @@ func configDefaultNginx(website *model.Website, domains []model.WebsiteDomain, a
225225
server.UpdateRoot(rootIndex)
226226
server.UpdatePHPProxy([]string{website.Proxy}, "")
227227
}
228-
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo:
229-
proxy := fmt.Sprintf("http://127.0.0.1:%d", runtime.Port)
230-
server.UpdateRootProxy([]string{proxy})
228+
case constant.RuntimeNode, constant.RuntimeJava, constant.RuntimeGo, constant.RuntimePython, constant.RuntimeDotNet:
229+
server.UpdateRootProxy([]string{fmt.Sprintf("http://%s", website.Proxy)})
231230
}
232231
case constant.Subsite:
233232
parentWebsite, err := websiteRepo.GetFirst(repo.WithByID(website.ParentWebsiteID))
@@ -760,14 +759,13 @@ func toMapStr(m map[string]interface{}) map[string]string {
760759
return ret
761760
}
762761

763-
func deleteWebsiteFolder(nginxInstall model.AppInstall, website *model.Website) error {
764-
nginxFolder := path.Join(global.Dir.AppInstallDir, constant.AppOpenresty, nginxInstall.Name)
765-
siteFolder := path.Join(nginxFolder, "www", "sites", website.Alias)
762+
func deleteWebsiteFolder(website *model.Website) error {
763+
siteFolder := GetSitePath(*website, SiteDir)
766764
fileOp := files.NewFileOp()
767765
if fileOp.Stat(siteFolder) {
768766
_ = fileOp.DeleteDir(siteFolder)
769767
}
770-
nginxFilePath := path.Join(nginxFolder, "conf", "conf.d", website.PrimaryDomain+".conf")
768+
nginxFilePath := GetSitePath(*website, SiteConf)
771769
if fileOp.Stat(nginxFilePath) {
772770
_ = fileOp.DeleteFile(nginxFilePath)
773771
}

frontend/src/api/interface/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export namespace Runtime {
1414
version: string;
1515
status: string;
1616
codeDir: string;
17-
port: number;
17+
port: string;
1818
appID: number;
1919
}
2020

frontend/src/lang/modules/en.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2294,6 +2294,8 @@ const message = {
22942294
changeDatabaseHelper2: 'Switching to another database will cause previous backups to be unrecoverable.',
22952295
saveCustom: 'Save as Template',
22962296
rainyun: 'Rain Yun',
2297+
volcengine: 'Volcengine',
2298+
runtimePortHelper: 'The current runtime environment has multiple ports. Please select a proxy port.',
22972299
},
22982300
php: {
22992301
short_open_tag: 'Short tag support',

frontend/src/lang/modules/ja.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,7 +1883,6 @@ const message = {
18831883
SSLList: '証明書リスト',
18841884
createDnsAccount: 'DNSアカウント',
18851885
aliyun: 'エイリアン',
1886-
volcengine: 'volcengine',
18871886
manual: '手動解析',
18881887
key: '鍵',
18891888
check: 'ビュー',
@@ -2156,6 +2155,8 @@ const message = {
21562155
changeDatabaseHelper2: '別のデータベースに切り替えると、以前のバックアップが復元できなくなる可能性があります。',
21572156
saveCustom: 'テンプレートとして保存',
21582157
rainyun: '雨雲',
2158+
volcengine: 'volcengine',
2159+
runtimePortHelper: '現在の実行環境には複数のポートがあります。プロキシポートを選択してください。',
21592160
},
21602161
php: {
21612162
short_open_tag: '短いタグサポート',

frontend/src/lang/modules/ko.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,6 @@ const message = {
18501850
SSLList: '인증서 목록',
18511851
createDnsAccount: 'DNS 계정 생성',
18521852
aliyun: '알리윤',
1853-
volcengine: '볼크엔진',
18541853
manual: '수동 설정',
18551854
key: '키',
18561855
check: '보기',
@@ -2119,6 +2118,8 @@ const message = {
21192118
changeDatabaseHelper2: '다른 데이터베이스로 전환하면 이전 백업을 복원할 수 없게 될 수 있습니다.',
21202119
saveCustom: '템플릿으로 저장',
21212120
rainyun: 'Rainyun',
2121+
volcengine: 'volcengine',
2122+
runtimePortHelper: '현재 실행 환경에 여러 포트가 있습니다. 프록시 포트를 선택하세요.',
21222123
},
21232124
php: {
21242125
short_open_tag: '짧은 태그 지원',

frontend/src/lang/modules/ms.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,6 @@ const message = {
19331933
SSLList: 'Senarai Sijil',
19341934
createDnsAccount: 'Akaun DNS',
19351935
aliyun: 'Aliyun',
1936-
volcengine: 'Volcengine',
19371936
manual: 'Penyelesaian Manual',
19381937
key: 'Kunci',
19391938
check: 'Lihat',
@@ -2208,6 +2207,8 @@ const message = {
22082207
'Menukar ke pangkalan data lain mungkin menyebabkan sandaran sebelumnya tidak dapat dipulihkan.',
22092208
saveCustom: 'Simpan sebagai Templat',
22102209
rainyun: 'Rainyun',
2210+
volcengine: 'Volcengine',
2211+
runtimePortHelper: 'Persekitaran runtime semasa mempunyai beberapa port. Sila pilih port proksi.',
22112212
},
22122213
php: {
22132214
short_open_tag: 'Sokongan tag pendek',

frontend/src/lang/modules/pt-br.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1926,7 +1926,6 @@ const message = {
19261926
SSLList: 'Lista de certificados',
19271927
createDnsAccount: 'Conta DNS',
19281928
aliyun: 'Aliyun',
1929-
volcengine: 'Volcengine',
19301929
manual: 'Análise manual',
19311930
key: 'Chave',
19321931
check: 'Ver',
@@ -2204,6 +2203,8 @@ const message = {
22042203
changeDatabaseHelper2: 'Alternar para outro banco de dados pode tornar backups anteriores irrecuperáveis.',
22052204
saveCustom: 'Salvar como Modelo',
22062205
rainyun: 'Rainyun',
2206+
volcengine: 'Volcengine',
2207+
runtimePortHelper: 'O ambiente de runtime atual possui várias portas. Por favor, selecione uma porta de proxy.',
22072208
},
22082209
php: {
22092210
short_open_tag: 'Suporte para short tags',

frontend/src/lang/modules/ru.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1925,7 +1925,6 @@ const message = {
19251925
SSLList: 'Список сертификатов',
19261926
createDnsAccount: 'DNS аккаунт',
19271927
aliyun: 'Aliyun',
1928-
volcengine: 'Volcengine',
19291928
manual: 'Ручная настройка',
19301929
key: 'Ключ',
19311930
check: 'Просмотр',
@@ -2204,6 +2203,8 @@ const message = {
22042203
'Переключение на другую базу данных может сделать предыдущие резервные копии невосстановимыми.',
22052204
saveCustom: 'Сохранить как Шаблон',
22062205
rainyun: 'Rainyun',
2206+
volcengine: 'Volcengine',
2207+
runtimePortHelper: 'O ambiente de runtime atual possui várias portas. Por favor, selecione uma porta de proxy.',
22072208
},
22082209
php: {
22092210
short_open_tag: 'Поддержка коротких тегов',

frontend/src/lang/modules/tw.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,6 +2132,8 @@ const message = {
21322132
changeDatabaseHelper2: '切換其他資料庫會導致以前的備份無法恢復。',
21332133
saveCustom: '另存为模版',
21342134
rainyun: '雨雲',
2135+
volcengine: 'Volcengine',
2136+
runtimePortHelper: '當前運行環境存在多個端口,請選擇一個代理端口。',
21352137
},
21362138
php: {
21372139
short_open_tag: '短標簽支持',

0 commit comments

Comments
 (0)