Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
4c5d6170
Commit
4c5d6170
authored
Dec 10, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/plugin: catch interrupts for every server
parent
06d12773
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
15 deletions
+6
-15
packer/plugin/plugin.go
packer/plugin/plugin.go
+6
-15
No files found.
packer/plugin/plugin.go
View file @
4c5d6170
...
@@ -92,28 +92,19 @@ func Server() (*packrpc.Server, error) {
...
@@ -92,28 +92,19 @@ func Server() (*packrpc.Server, error) {
return
nil
,
err
return
nil
,
err
}
}
// Serve a single connection
// Eat the interrupts
log
.
Println
(
"Serving a plugin connection..."
)
return
packrpc
.
NewServer
(
conn
),
nil
}
// Registers a signal handler to swallow and count interrupts so that the
// plugin isn't killed. The main host Packer process is responsible
// for killing the plugins when interrupted.
func
countInterrupts
()
{
ch
:=
make
(
chan
os
.
Signal
,
1
)
ch
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
ch
,
os
.
Interrupt
)
signal
.
Notify
(
ch
,
os
.
Interrupt
)
go
func
()
{
go
func
()
{
var
count
int32
=
0
for
{
for
{
<-
ch
<-
ch
newCount
:=
atomic
.
AddInt32
(
&
Interrupts
,
1
)
newCount
:=
atomic
.
AddInt32
(
&
count
,
1
)
log
.
Printf
(
"Received interrupt signal (count: %d). Ignoring."
,
newCount
)
log
.
Printf
(
"Received interrupt signal (count: %d). Ignoring."
,
newCount
)
}
}
}()
}()
}
// Tests whether or not the plugin was interrupted or not.
// Serve a single connection
func
Interrupted
()
bool
{
log
.
Println
(
"Serving a plugin connection..."
)
return
atomic
.
LoadInt32
(
&
Interrupts
)
>
0
return
packrpc
.
NewServer
(
conn
),
nil
}
}
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