Skip to content

Commit

Permalink
attempt reconnect if SQL server goes away
Browse files Browse the repository at this point in the history
  • Loading branch information
rikedyp committed Aug 28, 2024
1 parent d65acf4 commit 77add13
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
9 changes: 8 additions & 1 deletion APLSource/SQL.apln
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@
en←⊃msg
:If 0<en ⍝ Server error if database operation fails
SQA.Close cur
(3⊃msg)⎕SIGNAL 500
:If 2006=2 2⊃msg ⍝ SQL server has gone away
SQA.Close db
Connect ##.GetEnv¨'SQL_DATABASE' 'SQL_PASSWORD' 'SQL_USER'
:Else
(3⊃msg)⎕SIGNAL 500
:EndIf
:ElseIf 0>en ⍝ Print warnings to session and continue
⎕←msg
:EndIf
Expand All @@ -34,6 +39,8 @@
⎕←r
('Could not connect to ',⊃datasource)⎕SIGNAL⊃r
:EndIf
⎕←Do'create database if not exists dyalog_cms'
⎕←Use'dyalog_cms'
⎕←'Connected to SQL database: ',⊃datasource

Expand Down
2 changes: 0 additions & 2 deletions APLSource/Setup.aplf
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
GLOBAL.secrets←ReadJSON GetEnv'SECRETS'
⎕←'Initialising SQAPL...'
⎕←SQL.Connect GetEnv¨'SQL_DATABASE' 'SQL_PASSWORD' 'SQL_USER'
⎕←SQL.Do'create database if not exists dyalog_cms'
⎕←SQL.Use'dyalog_cms'
⎕←SQL.SetupSchema ⍬
⎕←SQL.ProcessTableInformation ⍬
:If 0=⎕NC'service'
Expand Down
2 changes: 1 addition & 1 deletion APLSource/Version.aplf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version←Version
version←'3.12.2'
version←'3.12.3'

0 comments on commit 77add13

Please sign in to comment.