mirror of
https://github.com/EvernodeXRPL/hp-devkit.git
synced 2026-04-29 15:37:58 +00:00
Add Restart Policy to hpdevkit container (#7)
This commit is contained in:
committed by
GitHub
parent
bd84875d04
commit
7e6554b232
@@ -54,6 +54,10 @@ function devKitContainer() {
|
||||
command+=" --entrypoint /bin/bash"
|
||||
fi
|
||||
|
||||
if [ ! -z "$RESTARTPOLICY" ]; then
|
||||
command+=" --restart $RESTARTPOLICY"
|
||||
fi
|
||||
|
||||
command+=" -e CLUSTER=$cluster -e CLUSTER_SIZE=$clusterSize -e DEFAULT_NODE=$defaultNode -e VOLUME=$volume -e NETWORK=$network"
|
||||
command+=" -e CONTAINER_PREFIX=$containerPrefix -e VOLUME_MOUNT=$volumeMount -e BUNDLE_MOUNT=$bundleMount -e HOTPOCKET_IMAGE=$instanceImage"
|
||||
command+=" -e CONFIG_OVERRIDES_FILE=$configOverridesFile -e CODEGEN_OUTPUT=$codegenOutputDir"
|
||||
@@ -96,7 +100,7 @@ function initializeDeploymentCluster() {
|
||||
AUTOREMOVE="true" MOUNTSOCK="true" CMD="cluster stop ; cluster create" devKitContainer run
|
||||
|
||||
# Spin up management container.
|
||||
NAME="$deploymentContainerName" DETACHED="true" MOUNTSOCK="true" MOUNTVOLUME="true" devKitContainer run
|
||||
NAME="$deploymentContainerName" DETACHED="true" MOUNTSOCK="true" MOUNTVOLUME="true" RESTARTPOLICY="unless-stopped" devKitContainer run
|
||||
|
||||
# Bind the instance mesh network config together.
|
||||
CONTAINERNAME="$deploymentContainerName" executeInContainer "cluster bindmesh"
|
||||
|
||||
@@ -23,7 +23,7 @@ $HPDevKitExeUrl = "$($CloudStorage)/hpdevkit-windows/hpdevkit.exe";
|
||||
$HPDevKitBackup = "\hpdevkit.exe.bak";
|
||||
$ExePath = (Get-Process -Id $pid).Path
|
||||
|
||||
function DevKitContainer([string]$Mode, [string]$Name, [switch]$Detached, [switch]$AutoRemove, [switch]$MountSock, [switch]$MountVolume, [string]$EntryPoint, [string]$Cmd, [switch]$Status) {
|
||||
function DevKitContainer([string]$Mode, [string]$Name, [switch]$Detached, [switch]$AutoRemove, [switch]$MountSock, [switch]$MountVolume, [string]$EntryPoint, [string]$RestartPolicy, [string]$Cmd, [switch]$Status) {
|
||||
|
||||
$Command = "docker $($Mode) -it"
|
||||
if ($Name) {
|
||||
@@ -51,6 +51,10 @@ function DevKitContainer([string]$Mode, [string]$Name, [switch]$Detached, [switc
|
||||
$Command += " --entrypoint /bin/bash"
|
||||
}
|
||||
|
||||
if ($RestartPolicy) {
|
||||
$Command += " --restart $($RestartPolicy)"
|
||||
}
|
||||
|
||||
# Pass environment variables used by our scripts.
|
||||
$Command += " -e CLUSTER=$($Cluster) -e CLUSTER_SIZE=$($ClusterSize) -e DEFAULT_NODE=$($DefaultNode) -e VOLUME=$($Volume) -e NETWORK=$($Network)"
|
||||
$Command += " -e CONTAINER_PREFIX=$($ContainerPrefix) -e VOLUME_MOUNT=$($VolumeMount) -e BUNDLE_MOUNT=$($BundleMount) -e HOTPOCKET_IMAGE=$($InstanceImage)"
|
||||
@@ -92,7 +96,7 @@ function InitializeDeploymentCluster() {
|
||||
DevKitContainer -Mode "run" -AutoRemove -MountSock -Cmd "cluster stop ; cluster create"
|
||||
|
||||
# Spin up management container.
|
||||
DevKitContainer -Mode "run" -Name $DeploymentContainerName -Detached -MountSock -MountVolume
|
||||
DevKitContainer -Mode "run" -Name $DeploymentContainerName -Detached -MountSock -MountVolume -RestartPolicy "unless-stopped"
|
||||
|
||||
# Bind the instance mesh network config together.
|
||||
ExecuteInDeploymentContainer -Cmd "cluster bindmesh"
|
||||
@@ -108,7 +112,7 @@ function TeardownDeploymentCluster() {
|
||||
Function Deploy([string]$Path) {
|
||||
|
||||
if ($Path) {
|
||||
|
||||
|
||||
InitializeDeploymentCluster
|
||||
|
||||
# If copying a directory, delete target bundle directory. If not create empty target bundle directory to copy a file.
|
||||
@@ -211,7 +215,17 @@ if (Test-Path -Path "$($ExePath)\$($HPDevKitBackup)") {
|
||||
Write-Host "HotPocket devkit launcher ($($Version))"
|
||||
|
||||
$Command = $args[0]
|
||||
$CommandError = "Invalid command. Expected: deploy | clean | start | stop | logs | gen | update"
|
||||
$CommandError = "Invalid command. Try 'hpdevkit help' for available commands."
|
||||
$HelpMessage = "Available commands: hpdevkit <COMMAND> <ARGUMENTS if any>
|
||||
COMMANDS:
|
||||
deploy <Contract path>
|
||||
clean
|
||||
start <Node number>
|
||||
stop <Node number>
|
||||
logs <Node number>
|
||||
gen <Platform> <App type> <Project name>
|
||||
update
|
||||
help"
|
||||
|
||||
if ($Command) {
|
||||
|
||||
@@ -219,6 +233,20 @@ if ($Command) {
|
||||
Write-Host "Code generator"
|
||||
CodeGenerator $args[1] $args[2] $args[3]
|
||||
}
|
||||
elseif ($Command -eq "help") {
|
||||
Write-Host $HelpMessage
|
||||
}
|
||||
elseif ($Command -eq "update") {
|
||||
try {
|
||||
if (Test-Path -Path "$($ExePath)\hpdevkit.exe") {
|
||||
UpdateHPDevKit
|
||||
}
|
||||
else {
|
||||
Write-Host "No HotPocket devkit executable file was found."
|
||||
}
|
||||
}
|
||||
catch { "An error occurred while updating." }
|
||||
}
|
||||
else {
|
||||
Write-Host "command: $($Command) (cluster: $($Cluster))"
|
||||
if ($Command -eq "deploy") {
|
||||
@@ -230,17 +258,6 @@ if ($Command) {
|
||||
elseif ($Command -eq "logs" -OR $Command -eq "start" -OR $Command -eq "stop") {
|
||||
DevKitContainer -Mode "run" -AutoRemove -MountSock -EntryPoint "cluster" -Cmd "$($args)"
|
||||
}
|
||||
elseif ($Command -eq "update") {
|
||||
try {
|
||||
if (Test-Path -Path "$($ExePath)\hpdevkit.exe") {
|
||||
UpdateHPDevKit
|
||||
}
|
||||
else {
|
||||
Write-Host "No HotPocket devkit executable file was found."
|
||||
}
|
||||
}
|
||||
catch { "An error occurred while updating." }
|
||||
}
|
||||
else {
|
||||
Write-Host $CommandError
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user