1 Daemonizing The Server
Skylar Grant edited this page 2025-01-06 18:35:10 -05:00

Daemonizing The Server

This page will walk you through the general steps of setting up the server as a daemon/service in Windows (Linux coming later).

Windows

Currently the server does not support running as a service in Windows. However, you can use a third-party tool like NSSM (Non-Sucking Service Manager) to instantiate a service. Here are the steps to do so:

  1. Download the latest version of NSSM from here
  2. Extract the downloaded zip file and navigate to the extracted folder (herein .\nssm)
  3. Open a command prompt with administrative privileges and navigate to .\nssm\win64
  4. Run the following command to open the NSSM service installation GUI:
    nssm install
    
  5. On the Application tab, set the following options:
    • Path:
      • %WINDIR%\System32\WindowsPowerShell\v1.0\powershell.exe
    • Startup directory:
      • C:\path\to\nsfw_ai_model_server
    • Arguments:
      • -ExecutionPolicy ByPass -NoExit -Command "& '<MINICONDA3_DIR>\shell\condabin\conda-hook.ps1'; conda activate '<MINICONDA3_DIR>'; start.ps1"
      • Change <MINICONDA3_DIR> to the path of your Miniconda3 installation directory (e.g. C:\Users\username\miniconda3)
    • Service name:
      • AI Tagger Server (or any other name you prefer)
  6. Optionally set the following options under the I/O Tab for logging:
    • Output file:
      • C:\path\to\nsfw_ai_model_server\logs\stdout.log
    • Error file:
      • C:\path\to\nsfw_ai_model_server\logs\stderr.log
  7. Click on the Install service button
  8. A diaglog box will confirm that the service has been installed. Click OK
  9. Open the Services application by pressing Win + R and typing services.msc
  10. Locate the service named AI Tagger Server (or the name you specified) and start it
  11. The AI Tagger server should now be running as a service

Uninstalling the service

To uninstall the service, follow these steps:

  1. Open a command prompt with administrative privileges and navigate to .\nssm\win64
  2. Run the following command:
    nssm remove "AI Tagger Server"
    
  3. The service should now be uninstalled