Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
ollama
Commits
0195d6a2
Unverified
Commit
0195d6a2
authored
Jun 20, 2024
by
Josh
Committed by
GitHub
Jun 20, 2024
Browse files
Merge pull request #5188 from ollama/jyan/tmpdir2
fix: skip os.removeAll() if PID does not exist
parents
fedf7163
662568d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
gpu/assets.go
gpu/assets.go
+19
-12
No files found.
gpu/assets.go
View file @
0195d6a2
...
@@ -77,20 +77,27 @@ func cleanupTmpDirs() {
...
@@ -77,20 +77,27 @@ func cleanupTmpDirs() {
continue
continue
}
}
raw
,
err
:=
os
.
ReadFile
(
filepath
.
Join
(
d
,
"ollama.pid"
))
raw
,
err
:=
os
.
ReadFile
(
filepath
.
Join
(
d
,
"ollama.pid"
))
if
err
==
nil
{
if
err
!=
nil
{
pid
,
err
:=
strconv
.
Atoi
(
string
(
raw
))
slog
.
Warn
(
"failed to read ollama.pid"
,
"path"
,
d
,
"error"
,
err
)
if
err
==
nil
{
// No pid, ignore this tmpdir
if
proc
,
err
:=
os
.
FindProcess
(
pid
);
err
==
nil
&&
!
errors
.
Is
(
proc
.
Signal
(
syscall
.
Signal
(
0
)),
os
.
ErrProcessDone
)
{
continue
// Another running ollama, ignore this tmpdir
continue
}
}
}
else
{
slog
.
Debug
(
"failed to open ollama.pid"
,
"path"
,
d
,
"error"
,
err
)
}
}
err
=
os
.
RemoveAll
(
d
)
pid
,
err
:=
strconv
.
Atoi
(
string
(
raw
))
if
err
!=
nil
{
if
err
!=
nil
{
slog
.
Debug
(
"unable to cleanup stale tmpdir"
,
"path"
,
d
,
"error"
,
err
)
slog
.
Warn
(
"failed to parse pid"
,
"path"
,
d
,
"error"
,
err
)
continue
}
proc
,
err
:=
os
.
FindProcess
(
pid
)
if
err
==
nil
&&
!
errors
.
Is
(
proc
.
Signal
(
syscall
.
Signal
(
0
)),
os
.
ErrProcessDone
)
{
slog
.
Warn
(
"found running ollama"
,
"pid"
,
pid
,
"path"
,
d
)
// Another running ollama, ignore this tmpdir
continue
}
if
err
:=
os
.
Remove
(
d
);
err
!=
nil
{
slog
.
Warn
(
"unable to cleanup stale tmpdir"
,
"path"
,
d
,
"error"
,
err
)
}
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment