Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
0fffd3ac
Unverified
Commit
0fffd3ac
authored
Mar 27, 2022
by
Martin Holst Swende
Committed by
GitHub
Mar 27, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
build: close sftp connection when done (#24593)
parent
eb3ebcea
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
util.go
internal/build/util.go
+28
-14
No files found.
internal/build/util.go
View file @
0fffd3ac
...
...
@@ -17,6 +17,7 @@
package
build
import
(
"bufio"
"bytes"
"flag"
"fmt"
...
...
@@ -116,7 +117,6 @@ func render(tpl *template.Template, outputFile string, outputPerm os.FileMode, x
// the form sftp://[user@]host[:port].
func
UploadSFTP
(
identityFile
,
host
,
dir
string
,
files
[]
string
)
error
{
sftp
:=
exec
.
Command
(
"sftp"
)
sftp
.
Stdout
=
os
.
Stdout
sftp
.
Stderr
=
os
.
Stderr
if
identityFile
!=
""
{
sftp
.
Args
=
append
(
sftp
.
Args
,
"-i"
,
identityFile
)
...
...
@@ -131,6 +131,10 @@ func UploadSFTP(identityFile, host, dir string, files []string) error {
if
err
!=
nil
{
return
fmt
.
Errorf
(
"can't create stdin pipe for sftp: %v"
,
err
)
}
stdout
,
err
:=
sftp
.
StdoutPipe
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"can't create stdout pipe for sftp: %v"
,
err
)
}
if
err
:=
sftp
.
Start
();
err
!=
nil
{
return
err
}
...
...
@@ -139,24 +143,34 @@ func UploadSFTP(identityFile, host, dir string, files []string) error {
fmt
.
Fprintln
(
in
,
"put"
,
f
,
path
.
Join
(
dir
,
filepath
.
Base
(
f
)))
}
fmt
.
Fprintln
(
in
,
"exit"
)
// Avoid travis timout after 10m of inactivity by printing something
// every 8 minutes.
done
:=
make
(
chan
bool
)
// Some issue with the PPA sftp server makes it so the server does not
// respond properly to a 'bye', 'exit' or 'quit' from the client.
// To work around that, we check the output, and when we see the client
// exit command, we do a hard exit.
// See
// https://github.com/kolban-google/sftp-gcs/issues/23
// https://github.com/mscdex/ssh2/pull/1111
aborted
:=
false
go
func
()
{
for
{
select
{
case
<-
time
.
After
(
8
*
time
.
Minute
)
:
fmt
.
Println
(
"keepalive log"
)
continue
case
<-
done
:
return
scanner
:=
bufio
.
NewScanner
(
stdout
)
for
scanner
.
Scan
()
{
txt
:=
scanner
.
Text
()
fmt
.
Println
(
txt
)
if
txt
==
"sftp> exit"
{
// Give it .5 seconds to exit (server might be fixed), then
// hard kill it from the outside
time
.
Sleep
(
500
*
time
.
Millisecond
)
aborted
=
true
sftp
.
Process
.
Kill
()
}
}
}()
stdin
.
Close
()
defer
close
(
done
)
return
sftp
.
Wait
()
err
=
sftp
.
Wait
()
if
aborted
{
return
nil
}
return
err
}
// FindMainPackages finds all 'main' packages in the given directory and returns their
...
...
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