Toggle navigation
Toggle navigation
This project
Loading...
Sign in
卢阳
/
front_backend_zImage
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
ly0303521
2026-01-21 17:31:46 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
93cd9db4c66a521508015a906faca0aa20c0751b
93cd9db4
1 parent
f0186ff2
添加网页前端后端启动脚本,以及增加日志管理功能
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
177 additions
and
5 deletions
.env.sh
.gitignore
start_all.sh
stop_all.sh
z-image-generator/constants.ts
z-image-generator/index.html
.env.sh
0 → 100644
View file @
93cd9db
# Shared Configuration
PUBLIC_IP
=
"106.120.52.146"
# Public Ports (External Access)
PUBLIC_BACKEND_PORT
=
"37000"
PUBLIC_FRONTEND_PORT
=
"37001"
PUBLIC_TURBO_PORT
=
"37002"
PUBLIC_OSS_PORT
=
"34000"
PUBLIC_ZIMAGE_PORT
=
"39009"
# Local Ports (Internal Bind)
LOCAL_BACKEND_PORT
=
"7000"
LOCAL_FRONTEND_PORT
=
"7001"
...
...
.gitignore
View file @
93cd9db
...
...
@@ -26,3 +26,5 @@ dist-ssr
backend/whitelist.txt
backend/gallery_images.json
backend/gallery_videos.json
z-image-generator/public
...
...
start_all.sh
0 → 100755
View file @
93cd9db
#!/bin/bash
BASE_DIR
=
$(
cd
"
$(
dirname
"
$0
"
)
"
;
pwd
)
# Load shared configuration
if
[
-f
"
$BASE_DIR
/.env.sh"
]
;
then
source
"
$BASE_DIR
/.env.sh"
else
echo
"Error: .env.sh not found in
$BASE_DIR
"
exit
1
fi
FRONTEND_DIR
=
"
$BASE_DIR
/z-image-generator"
BACKEND_DIR
=
"
$BASE_DIR
"
CONSTANTS_FILE
=
"
$FRONTEND_DIR
/constants.ts"
CONFIG_JS_FILE
=
"
$FRONTEND_DIR
/public/config.js"
LOGS_DIR
=
"
$BASE_DIR
/logs"
# Ensure logs directory exists
mkdir -p
"
$LOGS_DIR
"
# Function to rotate logs
rotate_log
()
{
local
log_file
=
"
$1
"
if
[
-f
"
$log_file
"
]
;
then
local
timestamp
=
$(
date +
"%Y%m%d_%H%M%S"
)
local
filename
=
$(
basename
"
$log_file
"
)
local
archived_log
=
"
$LOGS_DIR
/
${
filename
%.*
}
_
$timestamp
.log"
echo
"Rotating log:
$log_file
->
$archived_log
"
mv
"
$log_file
"
"
$archived_log
"
fi
}
echo
"=================================================="
echo
"Initializing Front-Backend Z-Image Services"
echo
"=================================================="
# 1. Generate Runtime Config (config.js)
echo
"Generating runtime configuration in
$CONFIG_JS_FILE
..."
# Ensure directory exists
mkdir -p
"
$(
dirname
"
$CONFIG_JS_FILE
"
)
"
cat >
"
$CONFIG_JS_FILE
"
<<EOF
window.APP_CONFIG = {
Z_IMAGE_DIRECT_BASE_URL: "http://$PUBLIC_IP:$PUBLIC_ZIMAGE_PORT",
TURBO_DIFFUSION_API_URL: "http://$PUBLIC_IP:$PUBLIC_TURBO_PORT",
VIDEO_OSS_BASE_URL: "http://$PUBLIC_IP:$PUBLIC_OSS_PORT",
API_BASE_URL: "http://$PUBLIC_IP:$PUBLIC_BACKEND_PORT"
};
EOF
echo
"Configuration generated."
# 2. Start Backend Service
echo
"--------------------------------------------------"
echo
"Starting Backend Service..."
echo
"Host: 0.0.0.0, Port:
$LOCAL_BACKEND_PORT
"
echo
"Public URL: http://
$PUBLIC_IP
:
$PUBLIC_BACKEND_PORT
"
cd
"
$BACKEND_DIR
"
||
exit
1
PID_BACKEND
=
$(
lsof -t -i:
$LOCAL_BACKEND_PORT
)
if
[
-n
"
$PID_BACKEND
"
]
;
then
echo
"Killing existing backend process on port
$LOCAL_BACKEND_PORT
(PID:
$PID_BACKEND
)..."
kill
-9
"
$PID_BACKEND
"
fi
rotate_log
"
$BASE_DIR
/backend.log"
# Use venv uvicorn
UVICORN_BIN
=
"
$BASE_DIR
/venv/bin/uvicorn"
if
[
! -f
"
$UVICORN_BIN
"
]
;
then
echo
"Warning: venv uvicorn not found at
$UVICORN_BIN
, trying system uvicorn..."
UVICORN_BIN
=
"uvicorn"
fi
nohup
"
$UVICORN_BIN
"
backend.main:app --host 0.0.0.0 --port
"
$LOCAL_BACKEND_PORT
"
> backend.log 2>&1 &
echo
"Backend started with PID:
$!
"
# 3. Start Frontend Service
echo
"--------------------------------------------------"
echo
"Starting Frontend Service..."
echo
"Host: 0.0.0.0, Port:
$LOCAL_FRONTEND_PORT
"
echo
"Public URL: http://
$PUBLIC_IP
:
$PUBLIC_FRONTEND_PORT
"
cd
"
$FRONTEND_DIR
"
||
exit
1
PID_FRONTEND
=
$(
lsof -t -i:
$LOCAL_FRONTEND_PORT
)
if
[
-n
"
$PID_FRONTEND
"
]
;
then
echo
"Killing existing frontend process on port
$LOCAL_FRONTEND_PORT
(PID:
$PID_FRONTEND
)..."
kill
-9
"
$PID_FRONTEND
"
fi
rotate_log
"
$BASE_DIR
/frontend.log"
export
VITE_API_BASE_URL
=
"http://
$PUBLIC_IP
:
$PUBLIC_BACKEND_PORT
"
nohup npm run dev -- --port
"
$LOCAL_FRONTEND_PORT
"
--host 0.0.0.0 > ../frontend.log 2>&1 &
echo
"Frontend started with PID:
$!
"
echo
"=================================================="
echo
"All services initiated."
...
...
stop_all.sh
0 → 100755
View file @
93cd9db
#!/bin/bash
BASE_DIR
=
$(
cd
"
$(
dirname
"
$0
"
)
"
;
pwd
)
# Load shared configuration
if
[
-f
"
$BASE_DIR
/.env.sh"
]
;
then
source
"
$BASE_DIR
/.env.sh"
else
echo
"Error: .env.sh not found in
$BASE_DIR
"
exit
1
fi
echo
"=================================================="
echo
"Stopping Front-Backend Z-Image Services"
echo
"=================================================="
# 1. Stop Backend Service
echo
"Checking Backend Service on port
$LOCAL_BACKEND_PORT
..."
PID_BACKEND
=
$(
lsof -t -i:
$LOCAL_BACKEND_PORT
)
if
[
-n
"
$PID_BACKEND
"
]
;
then
echo
"Found backend process (PID:
$PID_BACKEND
). Stopping..."
kill
-9
"
$PID_BACKEND
"
echo
"Backend service stopped."
else
echo
"No backend service found running on port
$LOCAL_BACKEND_PORT
."
fi
echo
"--------------------------------------------------"
# 2. Stop Frontend Service
echo
"Checking Frontend Service on port
$LOCAL_FRONTEND_PORT
..."
PID_FRONTEND
=
$(
lsof -t -i:
$LOCAL_FRONTEND_PORT
)
if
[
-n
"
$PID_FRONTEND
"
]
;
then
echo
"Found frontend process (PID:
$PID_FRONTEND
). Stopping..."
kill
-9
"
$PID_FRONTEND
"
echo
"Frontend service stopped."
else
echo
"No frontend service found running on port
$LOCAL_FRONTEND_PORT
."
fi
echo
"=================================================="
echo
"All Z-Image services stopped."
...
...
z-image-generator/constants.ts
View file @
93cd9db
import
{
ImageItem
}
from
'./types'
;
export
const
Z_IMAGE_DIRECT_BASE_URL
=
"http://106.120.52.146:39009"
;
// Declare global window object with APP_CONFIG
declare
global
{
interface
Window
{
APP_CONFIG
?:
{
Z_IMAGE_DIRECT_BASE_URL
?:
string
;
TURBO_DIFFUSION_API_URL
?:
string
;
VIDEO_OSS_BASE_URL
?:
string
;
API_BASE_URL
?:
string
;
}
}
}
const
config
=
typeof
window
!==
'undefined'
?
window
.
APP_CONFIG
||
{}
:
{};
export
const
Z_IMAGE_DIRECT_BASE_URL
=
config
.
Z_IMAGE_DIRECT_BASE_URL
||
"http://106.120.52.146:39009"
;
// Base URL for the TurboDiffusion AI service (submit job, poll status)
export
const
TURBO_DIFFUSION_API_URL
=
"http://106.120.52.146:38000"
;
export
const
TURBO_DIFFUSION_API_URL
=
config
.
TURBO_DIFFUSION_API_URL
||
"http://106.120.52.146:38000"
;
// Base URL for the OSS service that serves the final video files
export
const
VIDEO_OSS_BASE_URL
=
"http://106.120.52.146:39997"
;
export
const
VIDEO_OSS_BASE_URL
=
config
.
VIDEO_OSS_BASE_URL
||
"http://106.120.52.146:39997"
;
const
ENV_PROXY_URL
=
import
.
meta
.
env
?.
VITE_API_BASE_URL
?.
trim
();
const
DEFAULT_PROXY_URL
=
ENV_PROXY_URL
&&
ENV_PROXY_URL
.
length
>
0
const
DEFAULT_PROXY_URL
=
config
.
API_BASE_URL
||
(
ENV_PROXY_URL
&&
ENV_PROXY_URL
.
length
>
0
?
ENV_PROXY_URL
:
"http://106.120.52.146:37000"
;
:
"http://106.120.52.146:37000"
)
;
export
const
API_BASE_URL
=
DEFAULT_PROXY_URL
;
...
...
z-image-generator/index.html
View file @
93cd9db
...
...
@@ -4,6 +4,7 @@
<meta
charset=
"UTF-8"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<title>
Z-Image Generator
</title>
<script
src=
"/config.js"
></script>
<script
src=
"https://cdn.tailwindcss.com"
></script>
<script>
tailwind
.
config
=
{
...
...
Please
register
or
login
to post a comment