mirror of
https://github.com/XShengTech/MEGREZ.git
synced 2026-05-03 13:02:38 +00:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2bf6a58e7f | |||
| 69f91dba02 | |||
| 2a18684162 | |||
| e6f81e19dc | |||
| 05502938ba | |||
| 7fc2c3ec09 | |||
| 011827f5c7 | |||
| 69554b5e39 | |||
| a24fb8e8ad |
+4
-1
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.23.6-alpine AS builder
|
||||
FROM golang:1.24-alpine AS builder
|
||||
LABEL stage=gobuilder \
|
||||
mainatiner=https://github.com/XShengTech/MEGREZ
|
||||
|
||||
@@ -29,6 +29,9 @@ WORKDIR /app
|
||||
|
||||
COPY --from=builder /build/megrez /app/megrez
|
||||
|
||||
COPY --from=builder /usr/local/go/lib/time/zoneinfo.zip /opt/zoneinfo.zip
|
||||
ENV ZONEINFO=/opt/zoneinfo.zip
|
||||
|
||||
EXPOSE 34567
|
||||
|
||||
ENTRYPOINT ["./megrez"]
|
||||
@@ -0,0 +1,87 @@
|
||||
<script setup>
|
||||
import { useLayout } from '@/layout/composables/layout';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import AppAdminSidebar from './AppAdminSidebar.vue';
|
||||
import AppFooter from './AppFooter.vue';
|
||||
import AppTopbar from './AppTopbar.vue';
|
||||
|
||||
import api from '@/api';
|
||||
import { useProfileStore } from '@/stores/profile';
|
||||
import { useToast } from 'primevue/usetoast';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
const router = useRouter()
|
||||
const profileStore = useProfileStore()
|
||||
const toast = useToast()
|
||||
|
||||
const { layoutConfig, layoutState, isSidebarActive, resetMenu } = useLayout();
|
||||
|
||||
const outsideClickListener = ref(null);
|
||||
|
||||
watch(isSidebarActive, (newVal) => {
|
||||
if (newVal) {
|
||||
bindOutsideClickListener();
|
||||
} else {
|
||||
unbindOutsideClickListener();
|
||||
}
|
||||
});
|
||||
|
||||
const containerClass = computed(() => {
|
||||
return {
|
||||
'layout-overlay': layoutConfig.menuMode === 'overlay',
|
||||
'layout-static': layoutConfig.menuMode === 'static',
|
||||
'layout-static-inactive': layoutState.staticMenuDesktopInactive && layoutConfig.menuMode === 'static',
|
||||
'layout-overlay-active': layoutState.overlayMenuActive,
|
||||
'layout-mobile-active': layoutState.staticMenuMobileActive
|
||||
};
|
||||
});
|
||||
|
||||
function bindOutsideClickListener() {
|
||||
if (!outsideClickListener.value) {
|
||||
outsideClickListener.value = (event) => {
|
||||
if (isOutsideClicked(event)) {
|
||||
resetMenu();
|
||||
}
|
||||
};
|
||||
document.addEventListener('click', outsideClickListener.value);
|
||||
}
|
||||
}
|
||||
|
||||
function unbindOutsideClickListener() {
|
||||
if (outsideClickListener.value) {
|
||||
document.removeEventListener('click', outsideClickListener);
|
||||
outsideClickListener.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
function isOutsideClicked(event) {
|
||||
const sidebarEl = document.querySelector('.layout-sidebar');
|
||||
const topbarEl = document.querySelector('.layout-menu-button');
|
||||
|
||||
return !(sidebarEl.isSameNode(event.target) || sidebarEl.contains(event.target) || topbarEl.isSameNode(event.target) || topbarEl.contains(event.target));
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
api.GetUserProfile().then(res => {
|
||||
profileStore.setUserProfile(res.data.data.result)
|
||||
}).catch(_ => {
|
||||
toast.add({ severity: 'error', summary: '登录过期,请重新登录', life: 3000 })
|
||||
profileStore.clearUserProfile()
|
||||
router.push('/login')
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="layout-wrapper" :class="containerClass">
|
||||
<app-topbar></app-topbar>
|
||||
<app-admin-sidebar></app-admin-sidebar>
|
||||
<div class="layout-main-container">
|
||||
<div class="layout-main">
|
||||
<router-view></router-view>
|
||||
</div>
|
||||
<app-footer></app-footer>
|
||||
</div>
|
||||
<div class="layout-mask animate-fadein"></div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,88 @@
|
||||
<script setup>
|
||||
import { useProfileStore } from '@/stores/profile';
|
||||
import { onMounted, ref } from 'vue';
|
||||
|
||||
import AppMenuItem from './AppMenuItem.vue';
|
||||
|
||||
const profileStore = useProfileStore();
|
||||
|
||||
|
||||
const model = ref([]);
|
||||
|
||||
const defaultModel = ref({
|
||||
label: '用户中心',
|
||||
items: [
|
||||
{
|
||||
label: '实例管理',
|
||||
icon: 'pi pi-fw pi-desktop text-lime-500',
|
||||
to: '/'
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const adminModel = ref({
|
||||
label: '系统设置',
|
||||
items: [
|
||||
{
|
||||
label: '实例管理',
|
||||
icon: 'pi pi-fw pi-desktop text-lime-500',
|
||||
to: '/admin/instances'
|
||||
},
|
||||
{
|
||||
label: '用户管理',
|
||||
icon: 'pi pi-fw pi-users text-indigo-500',
|
||||
to: '/admin/users'
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
const superAdminModel = ref({
|
||||
label: '系统设置',
|
||||
items: [
|
||||
{
|
||||
label: '节点管理',
|
||||
icon: 'pi pi-fw pi-server text-yellow-400',
|
||||
to: '/admin/servers'
|
||||
},
|
||||
{
|
||||
label: '实例管理',
|
||||
icon: 'pi pi-fw pi-desktop text-lime-500',
|
||||
to: '/admin/instances'
|
||||
},
|
||||
{
|
||||
label: '用户管理',
|
||||
icon: 'pi pi-fw pi-users text-indigo-500',
|
||||
to: '/admin/users'
|
||||
},
|
||||
{
|
||||
label: '镜像管理',
|
||||
icon: 'pi pi-fw pi-images text-teal-500',
|
||||
to: '/admin/images'
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
const superAdmin = profileStore.isSuperAdmin
|
||||
const admin = profileStore.isAdmin
|
||||
|
||||
if (superAdmin) {
|
||||
model.value.push(superAdminModel.value)
|
||||
} else if (admin) {
|
||||
model.value.push(adminModel.value)
|
||||
}
|
||||
|
||||
model.value.push(defaultModel.value);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ul class="layout-menu">
|
||||
<template v-for="(item, i) in model" :key="item">
|
||||
<app-menu-item v-if="!item.separator" :item="item" :index="i"></app-menu-item>
|
||||
<li v-if="item.separator" class="menu-separator"></li>
|
||||
</template>
|
||||
</ul>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup>
|
||||
import AppAdminMenu from './AppAdminMenu.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="layout-sidebar">
|
||||
<app-admin-menu></app-admin-menu>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
@@ -67,15 +67,10 @@ const adminModel = ref({
|
||||
label: '系统设置',
|
||||
items: [
|
||||
{
|
||||
label: '实例管理',
|
||||
icon: 'pi pi-fw pi-desktop text-lime-500',
|
||||
label: '管理后台',
|
||||
icon: 'pi pi-fw pi-sliders-h text-yellow-500',
|
||||
to: '/admin/instances'
|
||||
},
|
||||
{
|
||||
label: '用户管理',
|
||||
icon: 'pi pi-fw pi-users text-indigo-500',
|
||||
to: '/admin/users'
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
@@ -83,25 +78,10 @@ const superAdminModel = ref({
|
||||
label: '系统设置',
|
||||
items: [
|
||||
{
|
||||
label: '节点管理',
|
||||
icon: 'pi pi-fw pi-server text-yellow-400',
|
||||
label: '管理后台',
|
||||
icon: 'pi pi-fw pi-sliders-h text-yellow-400',
|
||||
to: '/admin/servers'
|
||||
},
|
||||
{
|
||||
label: '实例管理',
|
||||
icon: 'pi pi-fw pi-desktop text-lime-500',
|
||||
to: '/admin/instances'
|
||||
},
|
||||
{
|
||||
label: '镜像管理',
|
||||
icon: 'pi pi-fw pi-images text-teal-500',
|
||||
to: '/admin/images'
|
||||
},
|
||||
{
|
||||
label: '用户管理',
|
||||
icon: 'pi pi-fw pi-users text-indigo-500',
|
||||
to: '/admin/users'
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Menu ref="profileMenu" :model="instanceMenuItems" :popup="true" @blur="profileMenuActive = false" />
|
||||
<Menu ref="profileMenu" :model="profileMenuItems" :popup="true" @blur="profileMenuActive = false" />
|
||||
</template>
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ const username = ref('');
|
||||
|
||||
const profileMenu = ref(null);
|
||||
const profileMenuActive = ref(false);
|
||||
const instanceMenuItems = [
|
||||
const profileMenuItems = ref([
|
||||
{
|
||||
label: '个人信息',
|
||||
icon: 'pi pi-user !text-cyan-500',
|
||||
@@ -78,6 +78,12 @@ const instanceMenuItems = [
|
||||
router.push('/settings');
|
||||
}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
]);
|
||||
|
||||
const profileExitItems = ref([
|
||||
{
|
||||
label: '退出登录',
|
||||
icon: 'pi pi-sign-out',
|
||||
@@ -86,7 +92,35 @@ const instanceMenuItems = [
|
||||
logout();
|
||||
}
|
||||
}
|
||||
];
|
||||
]);
|
||||
|
||||
const profileAdminItems = ref([
|
||||
{
|
||||
label: '管理后台',
|
||||
icon: 'pi pi-sliders-h !text-yellow-400',
|
||||
command: () => {
|
||||
profileMenu.value.hide();
|
||||
router.push('/admin/instances');
|
||||
}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
])
|
||||
|
||||
const profileSuperadminItems = ref([
|
||||
{
|
||||
label: '管理后台',
|
||||
icon: 'pi pi-sliders-h !text-yellow-400',
|
||||
command: () => {
|
||||
profileMenu.value.hide();
|
||||
router.push('/admin/servers');
|
||||
}
|
||||
},
|
||||
{
|
||||
separator: true
|
||||
},
|
||||
])
|
||||
|
||||
const showMenu = (event) => {
|
||||
profileMenu.value.show(event);
|
||||
@@ -105,6 +139,14 @@ const logout = () => {
|
||||
|
||||
onMounted(() => {
|
||||
username.value = profileStore.username;
|
||||
|
||||
if (profileStore.isSuperAdmin) {
|
||||
profileMenuItems.value.push(...profileSuperadminItems.value);
|
||||
} else if (profileStore.isAdmin) {
|
||||
profileMenuItems.value.push(...profileAdminItems.value);
|
||||
}
|
||||
|
||||
profileMenuItems.value.push(...profileExitItems.value);
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -4,10 +4,36 @@ const layoutConfig = reactive({
|
||||
preset: 'Aura',
|
||||
primary: 'blue',
|
||||
surface: null,
|
||||
darkTheme: false,
|
||||
darkTheme: window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches,
|
||||
menuMode: 'static'
|
||||
});
|
||||
|
||||
// Listen for changes to the prefers-color-scheme media query
|
||||
if (window.matchMedia) {
|
||||
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', (e) => {
|
||||
layoutConfig.darkTheme = e.matches;
|
||||
toggleDarkMode();
|
||||
});
|
||||
}
|
||||
|
||||
const toggleDarkMode = () => {
|
||||
if (!document.startViewTransition) {
|
||||
executeDarkModeToggle();
|
||||
return;
|
||||
}
|
||||
|
||||
document.startViewTransition(() => executeDarkModeToggle(event));
|
||||
};
|
||||
|
||||
if (layoutConfig.darkTheme) {
|
||||
toggleDarkMode()
|
||||
}
|
||||
|
||||
const executeDarkModeToggle = () => {
|
||||
layoutConfig.darkTheme = !layoutConfig.darkTheme;
|
||||
document.documentElement.classList.toggle('app-dark');
|
||||
};
|
||||
|
||||
const layoutState = reactive({
|
||||
staticMenuDesktopInactive: false,
|
||||
overlayMenuActive: false,
|
||||
@@ -39,21 +65,6 @@ export function useLayout() {
|
||||
layoutConfig.menuMode = mode;
|
||||
};
|
||||
|
||||
const toggleDarkMode = () => {
|
||||
if (!document.startViewTransition) {
|
||||
executeDarkModeToggle();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
document.startViewTransition(() => executeDarkModeToggle(event));
|
||||
};
|
||||
|
||||
const executeDarkModeToggle = () => {
|
||||
layoutConfig.darkTheme = !layoutConfig.darkTheme;
|
||||
document.documentElement.classList.toggle('app-dark');
|
||||
};
|
||||
|
||||
const onMenuToggle = () => {
|
||||
if (layoutConfig.menuMode === 'overlay') {
|
||||
layoutState.overlayMenuActive = !layoutState.overlayMenuActive;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import AppLayout from '@/layout/AppLayout.vue';
|
||||
import { useProfileStore } from '@/stores/profile';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
|
||||
import Forget from '@/views/Forget.vue';
|
||||
@@ -16,6 +17,7 @@ import Instances from '@/views/admin/Instances.vue';
|
||||
import Servers from '@/views/admin/Servers.vue';
|
||||
import Users from '@/views/admin/Users.vue';
|
||||
|
||||
import AppAdminLayout from '@/layout/AppAdminLayout.vue';
|
||||
import NotFound from '@/views/NotFound.vue';
|
||||
|
||||
const router = createRouter({
|
||||
@@ -69,24 +71,31 @@ const router = createRouter({
|
||||
path: 'settings',
|
||||
name: 'settings',
|
||||
component: Settings
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: 'admin/images',
|
||||
path: '/admin/',
|
||||
name: 'admin-dashboard',
|
||||
component: AppAdminLayout,
|
||||
children: [
|
||||
{
|
||||
path: 'images',
|
||||
name: 'admin-images',
|
||||
component: Images
|
||||
},
|
||||
{
|
||||
path: 'admin/instances',
|
||||
path: 'instances',
|
||||
name: 'admin-instances',
|
||||
component: Instances
|
||||
},
|
||||
{
|
||||
path: 'admin/servers',
|
||||
path: 'servers',
|
||||
name: 'admin-servers',
|
||||
component: Servers
|
||||
},
|
||||
{
|
||||
path: 'admin/users',
|
||||
path: 'users',
|
||||
name: 'admin-users',
|
||||
component: Users
|
||||
}
|
||||
@@ -100,4 +109,19 @@ const router = createRouter({
|
||||
]
|
||||
});
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const profileStore = useProfileStore();
|
||||
if (to.path.startsWith('/admin')) {
|
||||
if (!profileStore.isAdmin && !profileStore.isSuperAdmin) {
|
||||
next({ name: 'not-found' });
|
||||
return;
|
||||
}
|
||||
if ((to.path.endsWith('servers') || to.path.endsWith('settings')) && !profileStore.isSuperAdmin) {
|
||||
next({ name: 'not-found' });
|
||||
return;
|
||||
}
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
@@ -225,7 +225,7 @@
|
||||
</template>
|
||||
</Drawer>
|
||||
|
||||
<ConfirmDialog></ConfirmDialog>
|
||||
<ConfirmDialog :draggable="false"></ConfirmDialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -498,6 +498,9 @@ const instanceModify = async () => {
|
||||
setTimeout(() => {
|
||||
getInstances()
|
||||
}, 100);
|
||||
if (instanceConfiguration.value.cpu_only) {
|
||||
delete instanceConfiguration.value.gpu_count
|
||||
}
|
||||
await api.AdminInstancesModify(instanceDetail.value.id, instanceConfiguration.value).then(async (res) => {
|
||||
toast.add({ severity: 'success', summary: '调整配置', detail: '已调整配置', life: 3000 });
|
||||
instanceModifyVisible.value = false
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
</Popover>
|
||||
</div>
|
||||
|
||||
<Dialog v-model:visible="serverModifyVisible" modal :header="'编辑节点 - ' + serverDetail.name"
|
||||
<Dialog v-model:visible="serverModifyVisible" modal :header="'编辑节点 - ' + serverDetail.name" :draggable="false"
|
||||
:style="{ width: '42rem' }">
|
||||
<span class="text-surface-500 dark:text-surface-400 block mb-6">编辑节点配置</span>
|
||||
<div class="flex items-center gap-0 mb-4">
|
||||
@@ -183,7 +183,7 @@
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<Dialog v-model:visible="serverAddVisible" modal :header="'添加节点'" :style="{ width: '42rem' }">
|
||||
<Dialog v-model:visible="serverAddVisible" modal :header="'添加节点'" :draggable="false" :style="{ width: '42rem' }">
|
||||
<span class="text-surface-500 dark:text-surface-400 block mb-6">添加节点配置</span>
|
||||
<div class="flex items-center gap-0 mb-4">
|
||||
<label class="font-semibold w-20">名称:</label>
|
||||
@@ -269,7 +269,7 @@
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<ConfirmDialog></ConfirmDialog>
|
||||
<ConfirmDialog :draggable="false"></ConfirmDialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
@@ -39,7 +39,8 @@
|
||||
</Paginator>
|
||||
</div>
|
||||
|
||||
<Dialog v-model:visible="userModifyVisible" modal :header="'编辑用户 - ' + userData.username" :style="{ width: '25rem' }">
|
||||
<Dialog v-model:visible="userModifyVisible" modal :header="'编辑用户 - ' + userData.username" :draggable="false"
|
||||
:style="{ width: '25rem' }">
|
||||
<span class="text-surface-500 dark:text-surface-400 block mb-6">编辑用户信息</span>
|
||||
<div class="flex items-center gap-0 mb-4">
|
||||
<label class="font-semibold w-20">邮箱:</label>
|
||||
@@ -61,7 +62,7 @@
|
||||
</div>
|
||||
</Dialog>
|
||||
|
||||
<ConfirmDialog></ConfirmDialog>
|
||||
<ConfirmDialog :draggable="false"></ConfirmDialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
@@ -229,7 +229,7 @@
|
||||
</template>
|
||||
</Drawer>
|
||||
|
||||
<ConfirmDialog></ConfirmDialog>
|
||||
<ConfirmDialog :draggable="false"></ConfirmDialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
@@ -501,6 +501,9 @@ const instanceModify = async () => {
|
||||
setTimeout(() => {
|
||||
getInstances()
|
||||
}, 100);
|
||||
if (instanceConfiguration.value.cpu_only) {
|
||||
delete instanceConfiguration.value.gpu_count
|
||||
}
|
||||
await api.UserInstancesModify(instanceDetail.value.id, instanceConfiguration.value).then(async (res) => {
|
||||
toast.add({ severity: 'success', summary: '调整配置', detail: '已调整配置', life: 3000 });
|
||||
instanceModifyVisible.value = false
|
||||
|
||||
@@ -33,6 +33,10 @@ func modifyHandler(ctx iris.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.CpuOnly {
|
||||
req.GpuCount = nil
|
||||
}
|
||||
|
||||
if req.GpuCount != nil {
|
||||
if *req.GpuCount < 0 {
|
||||
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
||||
@@ -62,7 +66,17 @@ func modifyHandler(ctx iris.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.CpuOnly == instance.CpuOnly && req.CpuOnly {
|
||||
hasChanges := false
|
||||
if req.CpuOnly != instance.CpuOnly {
|
||||
hasChanges = true
|
||||
}
|
||||
if req.GpuCount != nil && *req.GpuCount != instance.GpuCount {
|
||||
hasChanges = true
|
||||
}
|
||||
if req.VolumeSize != nil && *req.VolumeSize != instance.VolumeSize {
|
||||
hasChanges = true
|
||||
}
|
||||
if !hasChanges {
|
||||
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -39,6 +39,10 @@ func modifyHandler(ctx iris.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.CpuOnly {
|
||||
req.GpuCount = nil
|
||||
}
|
||||
|
||||
if req.GpuCount != nil {
|
||||
if *req.GpuCount < 0 {
|
||||
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
||||
@@ -68,7 +72,17 @@ func modifyHandler(ctx iris.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if req.CpuOnly == instance.CpuOnly && req.CpuOnly {
|
||||
hasChanges := false
|
||||
if req.CpuOnly != instance.CpuOnly {
|
||||
hasChanges = true
|
||||
}
|
||||
if req.GpuCount != nil && *req.GpuCount != instance.GpuCount {
|
||||
hasChanges = true
|
||||
}
|
||||
if req.VolumeSize != nil && *req.VolumeSize != instance.VolumeSize {
|
||||
hasChanges = true
|
||||
}
|
||||
if !hasChanges {
|
||||
middleware.Error(ctx, middleware.CodeBadRequest, iris.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -43,9 +43,19 @@ func modify(serverID uint, data Data) (err error) {
|
||||
return errors.New("instance status error")
|
||||
}
|
||||
|
||||
if data.CpuOnly == instance.CpuOnly && data.CpuOnly {
|
||||
lc.Error("instance already cpu_only mode")
|
||||
return errors.New("instance already cpu_only mode")
|
||||
hasChanges := false
|
||||
if data.CpuOnly != instance.CpuOnly {
|
||||
hasChanges = true
|
||||
}
|
||||
if data.GpuCount != nil && *data.GpuCount != instance.GpuCount {
|
||||
hasChanges = true
|
||||
}
|
||||
if data.VolumeSize != nil && *data.VolumeSize != instance.VolumeSize {
|
||||
hasChanges = true
|
||||
}
|
||||
if !hasChanges {
|
||||
lc.Error("no changes")
|
||||
return errors.New("no changes")
|
||||
}
|
||||
|
||||
oldVolumeSize := instance.VolumeSize
|
||||
|
||||
@@ -51,6 +51,13 @@ func Start() {
|
||||
LogLevel: "disable",
|
||||
Charset: "UTF-8",
|
||||
EnableOptimizations: true,
|
||||
RemoteAddrHeaders: []string{
|
||||
"X-Real-Ip",
|
||||
"X-Forwarded-For",
|
||||
"CF-Connecting-IP",
|
||||
"True-Client-Ip",
|
||||
"X-Appengine-Remote-Addr",
|
||||
},
|
||||
}),
|
||||
iris.WithoutServerError(iris.ErrServerClosed),
|
||||
)
|
||||
|
||||
@@ -45,6 +45,15 @@ func patchGpu(ip string, port int, apikey string,
|
||||
Dest: "/root/megrez-tmp",
|
||||
},
|
||||
}
|
||||
data.GpuPatch = &gpuPatchStruct{
|
||||
GpuCount: gpuCount,
|
||||
}
|
||||
data.CpuPatch = &cpuPatchStruct{
|
||||
CpuCount: cpuCountPerGpu * gpuCount,
|
||||
}
|
||||
data.MemoryPatch = &MemoryPatchStruct{
|
||||
Memory: strconv.Itoa(memoryPerGpu*gpuCount) + "GB",
|
||||
}
|
||||
}
|
||||
|
||||
reqBytes, err := json.Marshal(data)
|
||||
|
||||
Reference in New Issue
Block a user