Skip to content

Commit

Permalink
Running directly to reduce memory overheads
Browse files Browse the repository at this point in the history
  • Loading branch information
bfren committed Oct 23, 2023
1 parent de7e0a4 commit fd7cef9
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 28 deletions.
34 changes: 34 additions & 0 deletions overlay/etc/nu/scripts/bf-aspnet/run.nu
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use bf

# Run preflight checks before executing process
export def preflight [...args] {
# load environment
bf env load

# manually set executing script
bf env set X aspnet/run

# verify ASPNET_ASSEMBLY is set
let assembly = bf env ASPNET_ASSEMBLY
let dir_live = bf env ASPNET_APP_LIVE

# verify assembly exists
let assembly_path = $"($dir_live)/($assembly)"
if (bf fs is_not_file $assembly_path) {
bf write notok $"($assembly_path) not found."
go_to_sleep 30sec
exit 66
}

# start application
bf write "Starting ASP.NET application."
bf write debug $" .. ($assembly_path)."
}

# Sleep the thread for a set about of time
def go_to_sleep [
for: duration # Amount of time to sleep for
] {
bf write $"Sleeping for ($for)."
sleep $for
}
40 changes: 12 additions & 28 deletions overlay/etc/s6-overlay/s6-rc.d/aspnet/run
Original file line number Diff line number Diff line change
@@ -1,33 +1,17 @@
#!/usr/bin/nu
#!/bin/withenv sh

use bf
use bf-s6
bf env load -x aspnet
set -euo pipefail

# Run ASP.NET application
def main [...args] {
# verify ASPNET_ASSEMBLY is set
let assembly = bf env ASPNET_ASSEMBLY
let dir_live = bf env ASPNET_APP_LIVE

# verify assembly exists
let assembly_path = $"($dir_live)/($assembly)"
if (bf fs is_not_file $assembly_path) {
bf write notok $"($assembly_path) not found."
go_to_sleep 30sec
exit 0
}
#======================================================================================================================
# Run preflight checks.
#======================================================================================================================

# start application
bf write "Starting ASP.NET application."
bf write debug $" .. ($assembly_path)."
^bf-x-as www dotnet $assembly_path
}
nu -c "use bf-aspnet run ; run preflight"

# Sleep the thread for a set about of time
def go_to_sleep [
for: duration # Amount of time to sleep for
] {
bf write $"Sleeping for ($for)."
sleep $for
}

#======================================================================================================================
# Start dotnet application.
#======================================================================================================================

s6-setuidgid www dotnet ${BF_ASPNET_APP_LIVE}/${BF_ASPNET_ASSEMBLY}

0 comments on commit fd7cef9

Please sign in to comment.