Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Transformerlab App
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
mirrored_repos
MachineLearning
TransformerLab
Transformerlab App
Commits
7aa4953f
Commit
7aa4953f
authored
7 months ago
by
ali asaria
Browse files
Options
Downloads
Patches
Plain Diff
resolve async call after server starts
parent
94d679af
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/util.ts
+14
-3
14 additions, 3 deletions
src/main/util.ts
src/renderer/components/Connect/LocalConnection.tsx
+9
-3
9 additions, 3 deletions
src/renderer/components/Connect/LocalConnection.tsx
with
23 additions
and
6 deletions
src/main/util.ts
+
14
−
3
View file @
7aa4953f
...
...
@@ -113,7 +113,7 @@ export async function startLocalServer() {
const
server_dir
=
await
getTransformerLabCodeDir
();
const
logFilePath
=
await
getLogFilePath
();
const
out
=
fs
.
openSync
(
logFilePath
,
'
a
'
);
const
err
=
fs
.
openSync
(
logFilePath
,
'
a
'
);
//
const err = fs.openSync(logFilePath, 'a');
// Need to call bash script through WSL on Windows
// Windows will not let you set a UNC directory to cwd
...
...
@@ -124,11 +124,11 @@ export async function startLocalServer() {
:
[
'
-l
'
,
path
.
join
(
server_dir
,
'
run.sh
'
)];
const
options
=
isPlatformWindows
()
?
{
stdio
:
[
'
ignore
'
,
out
,
err
],
//
stdio: ['ignore', out, err],
}
:
{
cwd
:
server_dir
,
stdio
:
[
'
ignore
'
,
out
,
err
],
//
stdio: ['ignore', out, err],
shell
:
'
/bin/bash
'
,
};
...
...
@@ -143,9 +143,20 @@ export async function startLocalServer() {
if
(
localServer
.
stderr
)
{
localServer
.
stderr
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
error
(
`stderr:
${
data
}
`
);
fs
.
writeSync
(
out
,
data
);
if
(
data
.
includes
(
'
Uvicorn running on
'
))
{
console
.
log
(
'
Server is running
'
);
resolve
({
status
:
'
success
'
,
code
:
0
});
}
});
}
localServer
.
stdout
.
on
(
'
data
'
,
(
data
)
=>
{
console
.
log
(
`stdout:
${
data
}
`
);
fs
.
writeSync
(
out
,
data
);
});
localServer
.
on
(
'
error
'
,
(
error_msg
)
=>
{
console
.
log
(
`child process failed:
${
error_msg
}
`
);
err_msg
=
error_msg
;
...
...
This diff is collapsed.
Click to expand it.
src/renderer/components/Connect/LocalConnection.tsx
+
9
−
3
View file @
7aa4953f
...
...
@@ -40,7 +40,7 @@ function setIntervalXTimes(
)
{
var
x
=
0
;
var
intervalID
=
window
.
setInterval
(
async
function
()
{
console
.
log
(
`Testing if
${
checkName
}
${
x
}
times`
);
console
.
log
(
`Testing if
${
checkName
}
${
x
}
of
${
repetitions
}
times`
);
const
response
=
await
callback
();
if
(
response
)
{
...
...
@@ -333,6 +333,7 @@ function RunServer({ activeStep, setActiveStep }) {
return
;
}
console
.
log
(
'
Starting Server
'
);
const
start_process
=
await
window
.
electron
.
ipcRenderer
.
invoke
(
'
server:startLocalServer
'
...
...
@@ -345,7 +346,12 @@ function RunServer({ activeStep, setActiveStep }) {
setThinking
(
false
);
return
;
}
// set interval to check if server is running every 2 seconds, 15 times:
console
.
log
(
'
Server has started
'
);
console
.
log
(
'
Start checking if the server is running after 0.150 seconds, 25 times
'
);
// set interval to check if server is running every 1 seconds, 25 times:
setIntervalXTimes
(
'
Server is Running on Port 8000
'
,
async
()
=>
{
...
...
@@ -364,7 +370,7 @@ function RunServer({ activeStep, setActiveStep }) {
);
setThinking
(
false
);
},
1
00
0
,
1
5
0
,
25
);
}
}
...
...
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