feat(controller): intial build functions setup in go and service building

This commit is contained in:
2025-09-05 09:14:34 -05:00
parent 8a07c8afe4
commit 87aafef350
13 changed files with 510 additions and 8 deletions

5
.gitignore vendored
View File

@@ -5,6 +5,11 @@ lstWrapper/bin
lstWrapper/obj
lstWrapper/publish
testScripts
.build
builds
# ignoring the old app that will be built into this one to make deploying faster and more easy as we do the migration
lstV2
# Logs
logs
*.log

13
.include Normal file
View File

@@ -0,0 +1,13 @@
dist
frontend/dist
lstDocs/build
lstWrapper/publish
migrations
Dockerfile
docker-compose.yml
README.md
CHANGELOG.md
package.json
package-lock.json
controller/lst_ctl.exe
lstV2

71
controller/Dockerfile Normal file
View File

@@ -0,0 +1,71 @@
# # ---- Builder Stage ----
# FROM golang:1.24.4-alpine3.22 AS builder
# WORKDIR /app/controller
# # Copy Go module manifests
# COPY controller/go.mod controller/go.sum ./
# RUN go mod download
# # Copy the controller source code
# COPY controller/ ./
# # Build the binary
# RUN CGO_ENABLED=0 GOOS=linux go build -o /app/lst_ctl .
# # ---- Runtime Stage ----
# FROM alpine:latest
# WORKDIR /root/
# # Copy only the binary (no need for sources)
# COPY --from=builder /app/lst_ctl .
# # (Optional) Persist data output if controller writes files
# RUN mkdir -p /data
# VOLUME /data
# # Expose Gin API port
# EXPOSE 8080
# ENV RUNNING_IN_DOCKER=true
# CMD ["./lst_ctl"]
# ---- Build Go binary ----
FROM golang:1.24.4-alpine3.22 AS gobuilder
WORKDIR /src
# copy controller module
COPY controller/go.mod controller/go.sum ./
RUN go mod download
# copy all controller source code
COPY controller/ ./
# build binary into /bin
RUN CGO_ENABLED=0 GOOS=linux go build -o /bin/lst_ctl .
# ---- Runtime with Node ----
FROM node:20-alpine
WORKDIR /app
# copy binary from builder
COPY --from=gobuilder /bin/lst_ctl /usr/local/bin/lst_ctl
# copy repo root into /app (npm needs package.json, dist/, frontend/, etc)
COPY . .
# clear Node's default entrypoint (Docker Hub node images use ["docker-entrypoint.sh"])
ENTRYPOINT []
# expose gin api
EXPOSE 8080
ENV RUNNING_IN_DOCKER=true
# run binary (in PATH now, since it's under /usr/local/bin)
CMD ["lst_ctl"]

17
controller/build_app.go Normal file
View File

@@ -0,0 +1,17 @@
package main
import (
"os"
"os/exec"
)
// ---- Run npm build ----
func runNpmBuild() error {
cmd := exec.Command("npm", "run", "build")
if os.Getenv("RUNNING_IN_DOCKER") == "true" {
cmd.Dir = "/app"
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

26
controller/build_v2app.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
"os"
"os/exec"
"path/filepath"
)
// ---- Run npm build ----
func runNpmV2Build() error {
cmd := exec.Command("npm", "run", "newBuild")
if os.Getenv("RUNNING_IN_DOCKER") == "true" {
cmd.Dir = "/app"
}else {
// Go three directories up from the current working directory
cwd, err := os.Getwd()
if err != nil {
return err
}
dir := filepath.Join(cwd, "..", "..", "lstV2")
cmd.Dir = dir
}
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}

26
controller/builds.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
"os"
"path/filepath"
)
// ensureBuildDir creates dir if missing
func ensureBuildDir(dir string) (string, error) {
if _, err := os.Stat(dir); os.IsNotExist(err) {
if err := os.MkdirAll(dir, 0755); err != nil {
return "", err
}
}
return filepath.Clean(dir), nil
}
func getBuildDir() (string, error) {
if os.Getenv("RUNNING_IN_DOCKER") == "true" {
// In Docker: workdir is usually /app/controller, so .. points to /app (repo root)
return ensureBuildDir(filepath.Join("..", "builds"))
}
// Local dev: still want builds in repo root relative to controller/
return ensureBuildDir(filepath.Join("..", "builds"))
}

26
controller/bump_build.go Normal file
View File

@@ -0,0 +1,26 @@
package main
import (
"fmt"
"os"
"strconv"
"strings"
)
// ---- Handle Build Counter ----
func bumpBuild() (int, error) {
data, err := os.ReadFile("../.build")
buildNum := 0
if err == nil { // if file exists, parse current number
num, err := strconv.Atoi(strings.TrimSpace(string(data)))
if err == nil {
buildNum = num
}
}
buildNum++
err = os.WriteFile("../.build", []byte(fmt.Sprintf("%d", buildNum)), 0644)
if err != nil {
return 0, err
}
return buildNum, nil
}

View File

@@ -0,0 +1,13 @@
services:
controller:
build:
context: .. # repo root
dockerfile: controller/Dockerfile
working_dir: /root
environment:
- RUNNING_IN_DOCKER=true
volumes:
- ..:/app # mount repo root for zipping, etc.
- ../builds:/builds # clean host->container builds mapping
ports:
- "8080:8080"

34
controller/go.mod Normal file
View File

@@ -0,0 +1,34 @@
module lst.net
go 1.24.3
require github.com/gin-gonic/gin v1.10.1
require (
github.com/bytedance/sonic v1.11.6 // indirect
github.com/bytedance/sonic/loader v0.1.1 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.20.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
github.com/leodido/go-urn v1.4.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/protobuf v1.34.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

79
controller/go.sum Normal file
View File

@@ -0,0 +1,79 @@
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
github.com/gin-gonic/gin v1.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ=
github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=

94
controller/main.go Normal file
View File

@@ -0,0 +1,94 @@
package main
import (
"fmt"
"log"
"os"
"path/filepath"
"strings"
"github.com/gin-gonic/gin"
)
func main() {
r := gin.Default()
// POST /build -> run npm build + increment .build
r.POST("/build", func(c *gin.Context) {
if err := runNpmBuild(); err != nil {
c.JSON(500, gin.H{"error": "npm build failed", "details": err.Error()})
return
}
buildNum, err := bumpBuild()
if err != nil {
c.JSON(500, gin.H{"error": "failed updating build counter", "details": err.Error()})
return
}
// run the zip
includes, _ := loadIncludePatterns("../.include")
// Name the archive after build number if available
data, _ := os.ReadFile("../.build")
buildNum1 := strings.TrimSpace(string(data))
if buildNum1 == "" {
buildNum1 = "0"
}
buildDir, err := getBuildDir()
if err != nil {
log.Fatal(err)
}
//buildDir, err := ensureBuildDir("../builds")
if err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}
zipPath := filepath.Join(buildDir, fmt.Sprintf("release-%d.zip", buildNum))
if err := zipProject("..", zipPath, includes); err != nil {
c.JSON(500, gin.H{"error": err.Error()})
return
}
c.JSON(200, gin.H{
"message": "build successful",
"build": buildNum,
})
})
r.POST("/buildv2", func(c *gin.Context) {
if err := runNpmV2Build(); err != nil {
c.JSON(500, gin.H{"error": "npm build failed on lstV2", "details": err.Error()})
return
}
buildNum, err := bumpBuild()
if err != nil {
c.JSON(500, gin.H{"error": "failed updating build counter", "details": err.Error()})
return
}
c.JSON(200, gin.H{
"message": "build successful",
"build": buildNum,
})
})
// GET /version -> read current build version
r.GET("/version", func(c *gin.Context) {
data, err := os.ReadFile(".build")
if err != nil {
c.JSON(404, gin.H{"error": "no build info"})
return
}
c.JSON(200, gin.H{"build": strings.TrimSpace(string(data))})
})
r.Run(":8080") // serve API
}

99
controller/zip_app.go Normal file
View File

@@ -0,0 +1,99 @@
package main
import (
"archive/zip"
"bufio"
"fmt"
"io"
"io/fs"
"os"
"path/filepath"
"strings"
)
// ---- Load ignore patterns ----
func loadIncludePatterns(file string) ([]string, error) {
f, err := os.Open(file)
if err != nil {
return nil, err
}
defer f.Close()
var patterns []string
scanner := bufio.NewScanner(f)
for scanner.Scan() {
line := strings.TrimSpace(scanner.Text())
if line == "" || strings.HasPrefix(line, "#") {
continue
}
patterns = append(patterns, filepath.ToSlash(filepath.Clean(line)))
}
return patterns, scanner.Err()
}
// ---- Simple matcher ----
// (Later swap for github.com/sabhiram/go-gitignore lib for proper rules)
func shouldInclude(path string, includes []string) bool {
cleanPath := filepath.ToSlash(filepath.Clean(path)) // normalize to forward slashes
for _, pat := range includes {
p := filepath.ToSlash(filepath.Clean(pat))
// exact match (file or folder)
if cleanPath == p {
return true
}
// if p is a folder, include all paths under it
if strings.HasPrefix(cleanPath, p+"/") {
return true
}
}
return false
}
// ---- Zip the repo ----
func zipProject(srcDir, zipFile string, includes []string) error {
outFile, err := os.Create(zipFile)
if err != nil {
return err
}
defer outFile.Close()
archive := zip.NewWriter(outFile)
defer archive.Close()
err = filepath.WalkDir(srcDir, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
relPath, _ := filepath.Rel(srcDir, path)
if !shouldInclude(relPath, includes) {
return nil // skip anything not explicitly included
}
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
info, _ := file.Stat()
header, _ := zip.FileInfoHeader(info)
header.Name = relPath
writer, err := archive.CreateHeader(header)
if err != nil {
return err
}
_, err = io.Copy(writer, file)
fmt.Println("Added:", relPath)
return err
})
return err
}

View File

@@ -11,18 +11,17 @@ param (
)
# Example string to run with the parameters in it.
# .\scripts\services.ps1 -serviceName "LST_ctl" -option "install" -appPath "E:\LST" -description "Logistics Support Tool controller" -command "E:\LST\controller\lst_app.exe"
# .C:\scripts\services.ps1 -serviceName "LST_ctl" -option "install" -appPath "E:\LST" -description "Logistics Support Tool controller" -command "E:\LST\controller\lst_ctl.exe"
# .\scripts\services.ps1 -serviceName "LST_app" -option "install" -appPath "E:\LST" -description "Logistics Support Tool" -command "run start"
$nssmPath = $AppPath + "\nssm.exe"
$npmPath = "C:\Program Files\nodejs\npm.cmd" # Path to npm.cmd
if($remote -eq "true"){
# Convert the plain-text password to a SecureString
$securePass = ConvertTo-SecureString $admpass -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential($username, $securePass)
if($remote -eq "true"){
# if(-not $username -or -not $admpass){
# Write-host "Missing adm account info please try again."
# exit 1
@@ -179,9 +178,9 @@ if($remote -eq "true"){
& $nssmPath set $serviceName Description $description
& $nssmPath set $serviceName AppStdout "E:\LST\logs\service.log"
& $nssmPath set $serviceName AppStderr "E:\LST\logs\service-error.log"
& $nssmPath set $serviceName DependOnService "MSSQLSERVER"
& $nssmPath set $serviceName AppStdout "$($appPath)\logs\service.log"
& $nssmPath set $serviceName AppStderr "$($appPath)\logs\service-error.log"
#& $nssmPath set $serviceName DependOnService "MSSQLSERVER"
# Set recovery options
sc.exe failure $serviceName reset= 0 actions= restart/5000/restart/5000/restart/5000
& $nssmPath start $serviceName