Skip to content

Examples & Recipes

Akram El Assas edited this page Feb 10, 2026 · 117 revisions

Table of Contents

  1. Introduction
  2. Note on --params Usage
  3. Run a Node.js / Next.js / Express App as a Service
  4. Run a Deno App as a Service
  5. Run a Bun App as a Service
  6. Run a Docker Container as a Service
  7. Run a Docker Compose Stack as a Service
  8. Run a Python Script as a Service
  9. Run a Go App as a Service
  10. Run a PocketBase Instance as a Service
  11. Run a Java JAR as a Service
  12. Run a Rust App as a Service
  13. Run a C/C++ Compiled App as a Service
  14. Run a PHP App as a Service
  15. Run a Laravel Queue Worker as a Service
  16. Run a Ruby App as a Service
  17. Run an Nginx Web Server as a Service
  18. Run a Redis Server as a Service
  19. Run a Haskell App as a Service
  20. Run a .NET App as a Service
  21. Run a PowerShell Script as a Service
  22. Run a Batch File as a Service
  23. Run an AutoHotkey Script as a Service
  24. Run a VBScript as a Service
  25. Run a WSL Bash Script as a Service
  26. Run a Julia Script as a Service
  27. Run a Dart Server or Script as a Service
  28. Run an R Script as a Service
  29. Run a Lua Script as a Service
  30. Run a Perl Script as a Service
  31. Run an OCaml Script or App as a Service
  32. Run a Zig App as a Service
  33. Run a Pascal/Delphi App as a Service
  34. Run a Fortran App as a Service
  35. Run an Elixir Script as a Service
  36. Run an Erlang Script as a Service
  37. Tips & Notes
  38. See Also

Introduction

Servy can turn any app into a native Windows service. On this page you'll find examples for the most popular languages and frameworks, ready to run as background services.

Services can be installed and configured easily through the Servy Desktop App or the PowerShell module, but this page focuses on real-world examples using the Servy CLI for automation, scripting, and CI/CD pipelines.

Once installed, the CLI executable is available at:

%ProgramFiles%\Servy\servy-cli.exe

After installation, the Servy directory is automatically added to the system PATH environment variable. This allows you to run servy-cli.exe directly from any elevated Command Prompt or PowerShell session.

Important

If you face any issues with the CLI in automated or non-interactive environments (e.g., CI/CD, Ansible, WinRM), use --quiet or -q options to suppress interactive output such as spinners or loading animations.

Starting with Servy 6.4+, the CLI automatically detects when no console is attached. You no longer need to pass --quiet manually. The CLI safely suppress spinners and console animations in non-interactive sessions (like SYSTEM tasks).

Note on --params Usage

Note

If the value of --params in install command includes arguments that start with --, use an equals sign (=) to prevent parsing issues. Example: --params="--mode=production --port=7008" Without the equals sign, the CLI might interpret --mode or --port as its own options instead of part of the service parameters.

Run a Node.js / Next.js / Express App as a Service

servy-cli install `
  --name="MyNodeApp" `
  --description="Node.js Express API" `
  --path="C:\Program Files\nodejs\node.exe" `
  --params="C:\apps\myapp\server.js" `
  --startupDir="C:\apps\myapp" `
  --startupType="Automatic"

Run an npm script (npm start) as a Service:

servy-cli install `
  --name="MyNodeApp" `
  --description="Node.js App via npm" `
  --path="C:\Program Files\nodejs\npm.cmd" `
  --params="start" `
  --startupDir="C:\apps\myapp" `
  --startupType="Automatic"

Run a Next.js Production App as a Service:

servy-cli install `
  --name="MyNextApp" `
  --description="Next.js App" `
  --path="C:\Program Files\nodejs\npm.cmd" `
  --params="start" `
  --startupDir="C:\apps\myapp" `
  --startupType="Automatic"

This runs:

npm start -> next start

which is the correct way to run Next.js in production.

Run a Deno App as a Service

servy-cli install `
  --name="MyDenoService" `
  --description="Deno background script" `
  --path="C:\tools\deno\deno.exe" `
  --params="run --allow-net C:\apps\deno\worker.ts" `
  --startupDir="C:\apps\deno" `
  --startupType="Automatic"

Notes:

  • The --allow-net flag is just an example; add other permissions (--allow-read, --allow-write, etc.) as needed.
  • Works for both scripts and Deno HTTP servers.

Run a Bun App as a Service

servy-cli install `
  --name="MyBunService" `
  --description="Bun backend service" `
  --path="C:\tools\bun\bun.exe" `
  --params="C:\apps\bun\server.ts" `
  --startupDir="C:\apps\bun" `
  --startupType="Automatic"

Notes:

  • Bun automatically detects whether the file is a script or server.
  • You can pass arguments like --port 3000 in --params if needed.

Run a Docker Container as a Service

servy-cli install `
  --name="MyDockerService" `
  --description="Docker container service" `
  --path="C:\Program Files\Docker\Docker\resources\bin\docker.exe" `
  --params="run --rm --name myapp -p 8080:80 myimage:latest" `
  --startupDir="C:\Program Files\Docker\Docker\resources\bin" `
  --startupType="Automatic"

Notes:

  • --rm ensures the container is cleaned up when it stops.
  • Adjust -p and myimage:latest as needed.

Run a Docker Compose Stack as a Service

servy-cli install `
  --name="MyDockerComposeService" `
  --description="Docker Compose stack service" `
  --path="C:\Program Files\Docker\Docker\resources\bin\docker-compose.exe" `
  --params="-f C:\apps\mycompose\docker-compose.yml up" `
  --startupDir="C:\apps\mycompose" `
  --startupType="Automatic"

Notes:

  • This runs the entire docker-compose.yml stack as a background service.

Run a Python Script as a Service

servy-cli install `
  --name="MyPythonJob" `
  --description="Python background job" `
  --path="C:\Python311\python.exe" `
  --params="C:\apps\scripts\job.py" `
  --startupDir="C:\apps\scripts" `
  --startupType="Automatic"

Run a Go App as a Service

servy-cli install `
  --name="MyGoService" `
  --description="Go background service" `
  --path="C:\apps\my-go-app\my-go-app.exe" `
  --params="--port=8080 --mode=worker" `
  --startupDir="C:\apps\my-go-app" `
  --startupType="Automatic"

Run a PocketBase Instance as a Service

PocketBase is a single-file backend that is highly effective when run as a service.

servy-cli install `
  --name="PocketBase" `
  --description="PocketBase backend" `
  --path="C:\apps\pocketbase\pocketbase.exe" `
  --params="serve --http=0.0.0.0:8090" `
  --startupDir="C:\apps\pocketbase" `
  --startupType="Automatic"

Run a Java JAR as a Service

servy-cli install `
  --name="MyJavaService" `
  --description="Java Spring Boot App" `
  --path="%JAVA_HOME%\bin\java.exe" `
  --params="-jar C:\apps\springboot\app.jar" `
  --startupDir="C:\apps\springboot" `
  --startupType="Automatic"

Run a Rust App as a Service

servy-cli install `
  --name="MyRustService" `
  --description="Rust background service" `
  --path="C:\apps\rustsvc\rust_svc.exe" `
  --startupDir="C:\apps\rustsvc" `
  --startupType="Automatic"

Run a C/C++ Compiled App as a Service

servy-cli install `
  --name="MyCppService" `
  --description="C++ Application" `
  --path="C:\apps\cpp-service\service.exe" `
  --startupDir="C:\apps\cpp-service" `
  --startupType="Automatic"

Run a PHP App as a Service

servy-cli install `
  --name="MyPHPWorker" `
  --description="PHP queue worker" `
  --path="C:\php\php.exe" `
  --params="C:\apps\worker\queue-worker.php" `
  --startupDir="C:\apps\worker" `
  --startupType="Automatic"

Run a Laravel Queue Worker as a Service

Ideal for handling background jobs in PHP/Laravel applications.

servy-cli install `
  --name="LaravelWorker" `
  --description="Laravel Queue Worker" `
  --path="C:\php\php.exe" `
  --params="artisan queue:work --tries=3" `
  --startupDir="C:\inetpub\wwwroot\myapp" `
  --startupType="Automatic"

Run a Ruby App as a Service

servy-cli install `
  --name="MyRubyApp" `
  --description="Ruby background app" `
  --path="C:\Ruby32\bin\ruby.exe" `
  --params="C:\apps\rubyapp\app.rb" `
  --startupDir="C:\apps\rubyapp" `
  --startupType="Automatic"

Run an Nginx Web Server as a Service

Running the Windows port of Nginx as a service ensures the web server persists across reboots.

servy-cli install `
  --name="Nginx" `
  --description="Nginx Web Server" `
  --path="C:\nginx\nginx.exe" `
  --startupDir="C:\nginx" `
  --startupType="Automatic"

Run a Redis Server as a Service

servy-cli install `
  --name="Redis" `
  --description="Redis In-Memory Data Store" `
  --path="C:\redis\redis-server.exe" `
  --params="redis.windows.conf" `
  --startupDir="C:\redis" `
  --startupType="Automatic"

Run a Haskell App as a Service

servy-cli install `
  --name="MyHaskellService" `
  --description="Haskell background worker" `
  --path="C:\apps\haskell\myapp.exe" `
  --startupDir="C:\apps\haskell" `
  --startupType="Automatic"

Run a .NET App as a Service

servy-cli install `
  --name="MyDotNetApp" `
  --description=".NET Worker Service" `
  --path="C:\apps\dotnetapp\MyApp.exe" `
  --startupDir="C:\apps\dotnetapp" `
  --startupType="Automatic"

Or, if using dotnet runtime with a DLL:

servy-cli install `
  --name="MyDotNetApp" `
  --description=".NET Worker Service" `
  --path="C:\Program Files\dotnet\dotnet.exe" `
  --params="C:\apps\dotnetapp\app.dll" `
  --startupDir="C:\apps\dotnetapp" `
  --startupType="Automatic"

Run a PowerShell script as a Service

servy-cli install `
  --name="MyPowerShellScript" `
  --description="Batch automation job" `
  --path="C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" `
  --params='-File \"C:\scripts\script\my script.ps1\"' `
  --startupDir="C:\scripts\script" `
  --startupType="Automatic" 

Run a Batch File as a Service

servy-cli install `
  --name="MyBatchScript" `
  --description="Batch automation job" `
  --path="C:\Windows\System32\cmd.exe" `
  --params="/c C:\scripts\backup-job.bat" `
  --startupDir="C:\scripts" `
  --startupType="Automatic"

Run an AutoHotkey script as a Service

Running AutoHotkey (AHK) as a service allows scripts to execute before user login.

Warning

Desktop Interaction: Windows services run in Session 0. This means scripts requiring GUI interaction, mouse movements, or keystrokes sent to active windows will not function correctly. Use service mode for background file monitoring or logic-only scripts.

servy-cli install `
  --name="MyAutoHotkeyService" `
  --description="Batch automation job" `
  --path="C:\Program Files\AutoHotkey\v2\AutoHotkey.exe" `
  --params="C:\scripts\service.ahk" `
  --startupDir="C:\scripts" `
  --startupType="Automatic"

Run a VBScript as a Service

servy-cli install `
  --name="MyVBScript" `
  --description="VBScript automation job" `
  --path="C:\Windows\System32\cscript.exe" `
  --params="C:\scripts\tasks\job.vbs" `
  --startupDir="C:\scripts\tasks" `
  --startupType="Automatic"

If you prefer wscript.exe (windowed, but still works as a service):

servy-cli install `
  --name="MyVBScript" `
  --description="VBScript automation job" `
  --path="C:\Windows\System32\wscript.exe" `
  --params="C:\scripts\tasks\job.vbs" `
  --startupDir="C:\scripts\tasks" `
  --startupType="Automatic"

Run a WSL Bash Script as a Service

servy-cli install `
  --name="MyWSLScript" `
  --description="WSL Bash script service" `
  --path="C:\Windows\System32\wsl.exe" `
  --params="bash /home/user/scripts/run.sh" `
  --startupDir="C:\Windows\System32" `
  --startupType="Automatic"

If you need a specific distribution:

servy-cli install `
  --name="MyUbuntuWSLService" `
  --description="WSL Ubuntu service job" `
  --path="C:\Windows\System32\wsl.exe" `
  --params="-d Ubuntu bash /home/user/app/start.sh" `
  --startupDir="C:\Windows\System32" `
  --startupType="Automatic"

Run a Julia Script as a Service

(Used for ML jobs, analytics, long-running computation workers)

servy-cli install `
  --name="MyJuliaService" `
  --description="Julia analytics worker" `
  --path="C:\Julia-1.10\bin\julia.exe" `
  --params="C:\apps\julia\worker.jl" `
  --startupDir="C:\apps\julia" `
  --startupType="Automatic"

Run a Dart Server or Script as a Service

(Shelf web services, background workers, API servers, etc.)

servy-cli install `
  --name="MyDartService" `
  --description="Dart backend service" `
  --path="C:\tools\dart-sdk\bin\dart.exe" `
  --params="C:\apps\dart\server.dart" `
  --startupDir="C:\apps\dart" `
  --startupType="Automatic"

Run an R Script as a Service

servy-cli install `
  --name="MyRService" `
  --description="R background job" `
  --path="C:\Program Files\R\R-4.4.1\bin\Rscript.exe" `
  --params="C:\apps\r\job.R" `
  --startupDir="C:\apps\r" `
  --startupType="Automatic"

Run a Lua Script as a Service

servy-cli install `
  --name="MyLuaService" `
  --description="Lua automation script" `
  --path="C:\Lua\5.4\lua.exe" `
  --params="C:\apps\lua\script.lua" `
  --startupDir="C:\apps\lua" `
  --startupType="Automatic"

Run a Perl Script as a Service

servy-cli install `
  --name="MyPerlService" `
  --description="Perl Script" `
  --path="C:\Perl64\bin\perl.exe" `
  --params="C:\apps\perl-task\task.pl" `
  --startupDir="C:\apps\perl-task" `
  --startupType="Automatic"

Run an OCaml Script or App as a Service

servy-cli install `
  --name="MyOCamlService" `
  --description="OCaml background worker" `
  --path="C:\OCaml\bin\ocaml.exe" `
  --params="C:\apps\ocaml\worker.ml" `
  --startupDir="C:\apps\ocaml" `
  --startupType="Automatic"

If you compiled your OCaml code to a native executable (e.g., worker.exe), you can skip ocaml.exe and set --path directly to the executable:

servy-cli install `
  --name="MyOCamlService" `
  --description="OCaml compiled worker" `
  --path="C:\apps\ocaml\worker.exe" `
  --startupDir="C:\apps\ocaml" `
  --startupType="Automatic"

This way, you can run either scripts or compiled OCaml apps as Windows services using Servy.

Run a Zig App as a Service

servy-cli install `
  --name="MyZigService" `
  --description="Zig background worker" `
  --path="C:\apps\zig\myapp.exe" `
  --startupDir="C:\apps\zig" `
  --startupType="Automatic"

Run a Pascal/Delphi App as a Service

servy-cli install `
  --name="MyPascalService" `
  --description="Delphi background app" `
  --path="C:\apps\pascal\worker.exe" `
  --startupDir="C:\apps\pascal" `
  --startupType="Automatic"

Run a Fortran App as a Service

servy-cli install `
  --name="MyFortranService" `
  --description="Fortran computational service" `
  --path="C:\apps\fortran\worker.exe" `
  --startupDir="C:\apps\fortran" `
  --startupType="Automatic"

Run an Elixir Script as a Service

servy-cli install `
  --name="MyElixirService" `
  --description="Elixir background worker" `
  --path="C:\Program Files\Elixir\bin\elixir.bat" `
  --params="C:\apps\elixir\worker.exs" `
  --startupDir="C:\apps\elixir" `
  --startupType="Automatic"

For Elixir, you can point --params to any .exs script or mix task.

Run an Erlang Script as a Service

servy-cli install `
  --name="MyErlangService" `
  --description="Erlang background worker" `
  --path="C:\Program Files\erl-25.3\bin\erl.exe" `
  --params="-noshell -s my_app start -s init stop" `
  --startupDir="C:\apps\erlang" `
  --startupType="Automatic"

For Erlang, the -s parameters start the desired module and function. Adjust according to your OTP app.

Tips & Notes

  • Environment Variables: If your application relies on specific environment variables (like JAVA_HOME), ensure they are set as System variables, as services run under the SYSTEM account by default.
  • Logging: Use the Servy Manager to configure log rotation and capture stdout/stderr for debugging background services.
  • Permissions: Ensure the service account has NTFS read/write permissions for the application's startup directory and %ProgramData\Servy%.

See Also

Clone this wiki locally