我创建一个脚本来检查服务器是否启动,如果服务器已关闭或没有响应,我重新启动它。我使用GETSTATE命令
Private Sub PrintReceipt()
On Error GoTo PrintReceipt_Error
Dim LineText As String, CellText As String
Dim TotalAmt As Currency, FormattedTotalAmt As String
Dim FileNum As Integer, FullFileName As String, i As Long, l As Long
FullFileName = NormalizePath(App.path) & "Receipt.txt"
FileNum = FreeFile
Open FullFileName For Output As #FileNum
Print #FileNum, "| " & Formatted("Qty.", "Text", 5) & " | " & Formatted("Product Name", "Text", 12) & " | " & Formatted("Unit Amt.", "Text", 9) & " | " & Formatted("Amount", "Text", 12) & " | "
Print #FileNum, String(2 * 2 + 3 * 3 + 5 + 12 + 9 + 12, "-")
l = ListView1.ListItems.Count
For i = 1 To l
LineText = "| "
CellText = ListView1.ListItems(i).SubItems(2) 'Quantity
LineText = LineText & Formatted(CellText, "Integer", 5) & " | "
CellText = ListView1.ListItems(i).SubItems(3) 'Product_Name
LineText = LineText & Formatted(CellText, "Text", 12) & " | "
CellText = ListView1.ListItems(i).SubItems(4) 'Price
LineText = LineText & Formatted(CellText, "Currency", 9) & " | "
CellText = ListView1.ListItems(i).SubItems(5) 'Total_Cost
LineText = LineText & Formatted(CellText, "Currency", 12) & " | "
TotalAmt = TotalAmt + CCur(CellText)
Print #FileNum, LineText
Next
FormattedTotalAmt = Format(TotalAmt, "0.00")
Print #FileNum, String(2 * 2 + 3 * 3 + 5 + 12 + 9 + 12, "-")
Print #FileNum, Formatted("", "Text", 2 + 3 + 5) & Formatted("Total Amount", "Text", 12) & String(27 - Len(FormattedTotalAmt), ".") & FormattedTotalAmt
Close #FileNum 'Close the file
Exit Sub
PrintReceipt_Error:
Close #FileNum 'Always close the file
End Sub
我每分钟运行一次以确保服务器正在运行,但有时需要太长时间,尽管服务器启动并处理请求。
如果它有帮助,使用http而不是t3?如果它与使用的协议无关,我可以做些什么来缩短时间,或者我如何检查服务器是否真的在运行并处理请求?