Add Android control app and embedded server
Inspired by HNKServer/honoka-chan-apk-server, but implemented as a JNI-based embedded runtime instead of the original approach. - Add an Android Compose controller app that starts and stops honoka-chan through JNI, shows runtime and health status, manages data directory mounting, and supports backup import/export for data.db - Add an embeddable Go server entrypoint plus JNI-exported status, health, and reload hooks so desktop and Android builds share the same startup and shutdown path - Add Android build scripts, runtime packaging, and project documentation, including generated default config.json content for honoka_runtime.zip - Add runtime bundle hash tracking so updated honoka_runtime.zip assets are automatically redeployed while preserving config.json and user data files - Add in-app service settings for unlock_all_special_rotation with immediate config persistence and automatic reload when the service is running - Split SQLite driver selection by platform, using go-sqlite3 on Android and modernc.org/sqlite elsewhere to avoid Android x86_64 seccomp crashes - Update startup, database initialization, and system health/reload handlers to support the embedded runtime and Android control flow Signed-off-by: Sean Du <do4suki@gmail.com>
This commit is contained in:
@@ -1,56 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"honoka-chan/config"
|
||||
_ "honoka-chan/internal/handler"
|
||||
"honoka-chan/internal/router"
|
||||
"honoka-chan/internal/startup"
|
||||
"honoka-chan/pkg/db"
|
||||
"context"
|
||||
"honoka-chan/internal/app"
|
||||
"log"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// 初始化配置
|
||||
config.InitConfig()
|
||||
|
||||
// 初始化数据库表和用户数据
|
||||
startup.StartUp()
|
||||
if err := app.Start("."); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
// 处理系统信号,确保程序退出时关闭数据库
|
||||
signalChan := make(chan os.Signal, 1)
|
||||
signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
<-signalChan
|
||||
log.Println("正在退出...")
|
||||
db.MainEng.Close()
|
||||
db.UserEng.Close()
|
||||
os.Exit(0)
|
||||
}()
|
||||
|
||||
// Gin
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
// Router
|
||||
r := gin.New()
|
||||
|
||||
// Logger
|
||||
r.Use(gin.LoggerWithConfig(gin.LoggerConfig{
|
||||
SkipPaths: []string{
|
||||
"/agreement/all",
|
||||
"/integration/appReport/initialize",
|
||||
"/report/ge/app",
|
||||
"/v1/account/reportRole",
|
||||
},
|
||||
}))
|
||||
|
||||
// SIF
|
||||
router.SifRouter(r)
|
||||
|
||||
r.Run(":" + config.Conf.Settings.ListenPort) // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
|
||||
<-signalChan
|
||||
log.Println("正在退出...")
|
||||
if err := app.Stop(context.Background()); err != nil {
|
||||
log.Println(err.Error())
|
||||
}
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user