Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Clash Verge
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Clash Verge
Commits
be81cd72
There was an error fetching the commit references. Please try again later.
Unverified
Commit
be81cd72
authored
2 years ago
by
GyDi
Browse files
Options
Downloads
Patches
Plain Diff
fix: adjust singleton detect
parent
4ae00714
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src-tauri/src/utils/server.rs
+11
-5
11 additions, 5 deletions
src-tauri/src/utils/server.rs
with
11 additions
and
5 deletions
src-tauri/src/utils/server.rs
+
11
−
5
View file @
be81cd72
...
...
@@ -2,19 +2,26 @@ extern crate warp;
use
super
::
resolve
;
use
crate
::
config
::
IVerge
;
use
anyhow
::{
bail
,
Result
};
use
port_scanner
::
local_port_available
;
use
tauri
::
AppHandle
;
use
warp
::
Filter
;
/// check whether there is already exists
pub
fn
check_singleton
()
->
Result
<
(),
()
>
{
pub
fn
check_singleton
()
->
Result
<
()
>
{
let
port
=
IVerge
::
get_singleton_port
();
if
!
local_port_available
(
port
)
{
tauri
::
async_runtime
::
block_on
(
async
{
let
url
=
format!
(
"http://127.0.0.1:{}/commands/visible"
,
port
);
reqwest
::
get
(
url
)
.await
.unwrap
();
Err
(())
let
url
=
format!
(
"http://127.0.0.1:{port}/commands/visible"
);
let
resp
=
reqwest
::
get
(
url
)
.await
?
.text
()
.await
?
;
if
&
resp
==
"ok"
{
bail!
(
"app exists"
);
}
log
::
error!
(
"failed to setup singleton listen server"
);
Ok
(())
})
}
else
{
Ok
(())
...
...
@@ -24,7 +31,6 @@ pub fn check_singleton() -> Result<(), ()> {
/// The embed server only be used to implement singleton process
/// maybe it can be used as pac server later
pub
fn
embed_server
(
app_handle
:
AppHandle
)
{
let
app_handle
=
app_handle
.clone
();
let
port
=
IVerge
::
get_singleton_port
();
tauri
::
async_runtime
::
spawn
(
async
move
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment