aboutsummaryrefslogtreecommitdiff
path: root/session.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2023-12-14 19:21:12 +0700
committerShulhan <ms@kilabit.info>2023-12-14 20:23:47 +0700
commitd281c094b88ab6bb2d6ccd0eb572d4275a9ab371 (patch)
tree25efe987274b1135157e8d235abc3d5de219e079 /session.go
parent1b1f3962ff42ee12ae6c573909629b61411cbddf (diff)
downloadawwan-d281c094b88ab6bb2d6ccd0eb572d4275a9ab371.tar.xz
all: close the SSH connection once Play finished
Previously, we used to run awwan as CLI so each connection is open and closed (forcefully). Since we now use awwan WUI frequently, any command that execute Play does not close the session immediately once finished. This cause many connections open in remote server. This changes close the SSH connections immediately once the Play command finished.
Diffstat (limited to 'session.go')
-rw-r--r--session.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/session.go b/session.go
index 9f33094..52f0388 100644
--- a/session.go
+++ b/session.go
@@ -410,6 +410,16 @@ func ExecLocal(req *ExecRequest, stmt *Statement) (err error) {
return nil
}
+// close the session and release all resources.
+func (ses *Session) close() (err error) {
+ ses.cryptoc = nil
+ if ses.sshc != nil {
+ err = ses.sshc.close()
+ ses.sshc = nil
+ }
+ return err
+}
+
// executeRequires run the "#require:" statements from line 0 until
// the start argument in the local system.
func (ses *Session) executeRequires(req *ExecRequest, pos linePosition) (err error) {