Hosting ASP.NET Core on nginx and Slackware

Published: 4/17/2026

The problem

There is a lot of documentation for hosting ASP.NET on Ubuntu, RHEL, and SUSE that all use systemd, but those of us not using systemd (such as Slackware) are left without.

Slackware uses a customized init system which consists of a collection of bash scripts in the /etc/rc.d directory. All existing documentation assumes creating a service file for use with systemd.

The Process

I've been using Slackware off and on since about 2009 so I was fairly familiar with the process of installing external packages. I got .NET 10 and nginx installed (nginx was a little troublesome, but that was on me) but still needed to figure out how to run the .NET application as a "service" to run the background.

I could get it to run from the command line, and could hit it from a browser on another network, so that was a good start. I thought maybe the rc.d initialization might somehow manage the background process (and it still might have except I needed to start it manually without rebooting).

After some research I found the command modifications I couldn't remember.

The Solution

UPDATE: Now includes start/stop/restart arguments

#!/bin/sh

RUN_AS="webuser"
PROGRAM_NAME="dotnet"
PROGRAM=/usr/bin/$PROGRAM_NAME; [ -x "$PROGRAM" ] || PROGRAM=/usr/local/bin/$PROGRAM_NAME
OPTIONS="/path/to/app.dll"
APP_DIR="/path/to"
LOG_FILE="/var/log/app.log"

start() {
  if pgrep -u "$RUN_AS" -f "$OPTIONS" > /dev/null; then
    echo "${PROGRAM_NAME} is already running."
    return 0
  fi
  echo "Starting ${PROGRAM_NAME}..."
  cd "$APP_DIR" || { echo "Cannot cd to $APP_DIR"; exit 1; }
  runuser -u "$RUN_AS" -- nohup $PROGRAM $OPTIONS >> "$LOG_FILE" 2>&1 &
}

stop() {
  PIDS=$(pgrep -u "$RUN_AS" -f "$OPTIONS")
  if [ -z "$PIDS" ]; then
    echo "${PROGRAM_NAME} is not running."
    return 0
  fi
  echo "Shutting down ${PROGRAM}..."
  if kill -TERM $(PIDS); then
      echo "Process terminated successfully."
  else
      echo "Failed to terminate the process."
  fi
}

status() {
  PIDS=$(pgrep -u "$RUN_AS" -f "$OPTIONS")
  if [ -z "$PIDS" ]; then
    echo "${PROGRAM_NAME} is not running!"
  else
    echo "${PROGRAM_NAME} is running at pid(s) ${PIDS}."
  fi
}

restart() {
  stop
  sleep 3
  start
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    restart
    ;;
  status)
    status
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
esac
                

About the Author

Adam is the lead developer at Manwaring Web Solutions. Programming since the age of 10, he taught himself HTML and basic CSS.