mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-04 20:14:57 +08:00
61 lines
2 KiB
Elixir
61 lines
2 KiB
Elixir
<%
|
|
|
|
app_name = Keyword.fetch!(@app_options, :name)
|
|
|
|
additional_paths =
|
|
for path <- Keyword.fetch!(@app_options, :additional_paths), into: "" do
|
|
"root & \"\\" <> String.replace(path, "/", "\\") <> ";\" & "
|
|
end
|
|
|
|
%>
|
|
|
|
Imports System
|
|
|
|
Module Launcher
|
|
Sub Main(args As String())
|
|
Dim root = My.Application.Info.DirectoryPath
|
|
Dim script = root & "\rel\bin\<%= @release.name %>.bat"
|
|
|
|
Dim input as String
|
|
If args.count > 0 Then
|
|
input = args(0)
|
|
Else
|
|
input = "open_app"
|
|
End If
|
|
|
|
<%= if additional_paths != "" do %>
|
|
Environment.SetEnvironmentVariable("PATH", <%= additional_paths%>Environment.GetEnvironmentVariable("PATH"))
|
|
<% end %>
|
|
|
|
' try release rpc, if release is down, this will fail but that's ok.
|
|
Dim rpcProc = new System.Diagnostics.Process()
|
|
rpcProc.StartInfo.FileName = "cmd.exe"
|
|
rpcProc.StartInfo.Arguments = "/c echo " & input & " | """ & script & """ rpc ""AppBundler.__rpc__()"""
|
|
rpcProc.StartInfo.UseShellExecute = false
|
|
rpcProc.StartInfo.CreateNoWindow = true
|
|
rpcProc.Start()
|
|
rpcProc.WaitForExit()
|
|
|
|
' rpc failed which usually means the release is down, let's start it
|
|
If rpcProc.ExitCode <> 0 Then
|
|
Environment.SetEnvironmentVariable("APP_BUILDER_INPUT", input)
|
|
Dim startProc = new System.Diagnostics.Process()
|
|
startProc.StartInfo.FileName = "cmd.exe"
|
|
startProc.StartInfo.Arguments = "/c """ & script & """ start"
|
|
startProc.StartInfo.UseShellExecute = false
|
|
startProc.StartInfo.CreateNoWindow = true
|
|
startProc.StartInfo.RedirectStandardError = true
|
|
startProc.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8
|
|
startProc.Start()
|
|
Dim errorMessage = startProc.StandardError.ReadToEnd()
|
|
startProc.WaitForExit()
|
|
|
|
If startProc.ExitCode <> 0 Then
|
|
MsgBox(
|
|
"<%= app_name %> exited with error code " & startProc.ExitCode & "." & vbCrLf & errorMessage,
|
|
MsgBoxStyle.Critical
|
|
)
|
|
End If
|
|
End If
|
|
End Sub
|
|
End Module
|