chore: Separate configuration for android build in release mode
This commit is contained in:
parent
4205b2a479
commit
21d0943aa4
@ -91,3 +91,11 @@ windows-sys = { version = "0.60.2", features = ["Win32_Storage_FileSystem"] }
|
||||
tauri-plugin-updater = "2"
|
||||
once_cell = "1.18"
|
||||
tauri-plugin-single-instance = { version = "2.0.0", features = ["deep-link"] }
|
||||
|
||||
# Release profile optimizations for minimal binary size
|
||||
[profile.release]
|
||||
opt-level = "z" # Optimize for size
|
||||
lto = true # Enable Link Time Optimization
|
||||
strip = true # Strip symbols for smaller binary
|
||||
codegen-units = 1 # Reduce parallel codegen for better optimization
|
||||
panic = "abort" # Don't unwind on panic, saves space
|
||||
|
||||
@ -14,12 +14,12 @@ pub async fn start_server<R: Runtime>(
|
||||
api_key: String,
|
||||
trusted_hosts: Vec<String>,
|
||||
proxy_timeout: u64,
|
||||
) -> Result<bool, String> {
|
||||
) -> Result<u16, String> {
|
||||
let server_handle = state.server_handle.clone();
|
||||
let plugin_state: State<LlamacppState> = app_handle.state();
|
||||
let sessions = plugin_state.llama_server_process.clone();
|
||||
|
||||
proxy::start_server(
|
||||
let actual_port = proxy::start_server(
|
||||
server_handle,
|
||||
sessions,
|
||||
host,
|
||||
@ -31,7 +31,7 @@ pub async fn start_server<R: Runtime>(
|
||||
)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(true)
|
||||
Ok(actual_port)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
|
||||
@ -632,7 +632,7 @@ pub async fn start_server(
|
||||
proxy_api_key: String,
|
||||
trusted_hosts: Vec<Vec<String>>,
|
||||
proxy_timeout: u64,
|
||||
) -> Result<bool, Box<dyn std::error::Error + Send + Sync>> {
|
||||
) -> Result<u16, Box<dyn std::error::Error + Send + Sync>> {
|
||||
let mut handle_guard = server_handle.lock().await;
|
||||
if handle_guard.is_some() {
|
||||
return Err("Server is already running".into());
|
||||
@ -667,7 +667,8 @@ pub async fn start_server(
|
||||
});
|
||||
|
||||
let server = Server::bind(&addr).serve(make_svc);
|
||||
log::info!("Jan API server started on http://{}", addr);
|
||||
let actual_addr = server.local_addr();
|
||||
log::info!("Jan API server started on http://{}", actual_addr);
|
||||
|
||||
let server_task = tokio::spawn(async move {
|
||||
if let Err(e) = server.await {
|
||||
@ -678,7 +679,9 @@ pub async fn start_server(
|
||||
});
|
||||
|
||||
*handle_guard = Some(server_task);
|
||||
Ok(true)
|
||||
let actual_port = actual_addr.port();
|
||||
log::info!("Jan API server started successfully on port {}", actual_port);
|
||||
Ok(actual_port)
|
||||
}
|
||||
|
||||
pub async fn stop_server(
|
||||
|
||||
7
src-tauri/tauri.android.conf.json
Normal file
7
src-tauri/tauri.android.conf.json
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"app": {
|
||||
"security": {
|
||||
"capabilities": ["default"]
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,12 @@
|
||||
{
|
||||
"app": {
|
||||
"security": {
|
||||
"capabilities": ["default"]
|
||||
}
|
||||
},
|
||||
"bundle": {
|
||||
"iOS": {
|
||||
"developmentTeam": "<DEVELOPMENT_TEAM_ID>"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,7 +40,8 @@ export const useLocalApiServer = create<LocalApiServerState>()(
|
||||
setEnableOnStartup: (value) => set({ enableOnStartup: value }),
|
||||
serverHost: '127.0.0.1',
|
||||
setServerHost: (value) => set({ serverHost: value }),
|
||||
serverPort: 1337,
|
||||
// Use port 0 (auto-assign) for mobile to avoid conflicts, 1337 for desktop
|
||||
serverPort: (typeof window !== 'undefined' && (window as any).IS_ANDROID) || (typeof window !== 'undefined' && (window as any).IS_IOS) ? 0 : 1337,
|
||||
setServerPort: (value) => set({ serverPort: value }),
|
||||
apiPrefix: '/v1',
|
||||
setApiPrefix: (value) => set({ apiPrefix: value }),
|
||||
|
||||
@ -31,6 +31,7 @@ export function DataProvider() {
|
||||
enableOnStartup,
|
||||
serverHost,
|
||||
serverPort,
|
||||
setServerPort,
|
||||
apiPrefix,
|
||||
apiKey,
|
||||
trustedHosts,
|
||||
@ -173,7 +174,11 @@ export function DataProvider() {
|
||||
proxyTimeout: proxyTimeout,
|
||||
})
|
||||
})
|
||||
.then(() => {
|
||||
.then((actualPort: number) => {
|
||||
// Store the actual port that was assigned (important for mobile with port 0)
|
||||
if (actualPort && actualPort !== serverPort) {
|
||||
setServerPort(actualPort)
|
||||
}
|
||||
setServerStatus('running')
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
|
||||
@ -48,6 +48,7 @@ function LocalAPIServerContent() {
|
||||
setEnableOnStartup,
|
||||
serverHost,
|
||||
serverPort,
|
||||
setServerPort,
|
||||
apiPrefix,
|
||||
apiKey,
|
||||
trustedHosts,
|
||||
@ -162,7 +163,11 @@ function LocalAPIServerContent() {
|
||||
proxyTimeout: proxyTimeout,
|
||||
})
|
||||
})
|
||||
.then(() => {
|
||||
.then((actualPort: number) => {
|
||||
// Store the actual port that was assigned (important for mobile with port 0)
|
||||
if (actualPort && actualPort !== serverPort) {
|
||||
setServerPort(actualPort)
|
||||
}
|
||||
setServerStatus('running')
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user