bitfocus / companion

Bitfocus Companion enables the reasonably priced Elgato Stream Deck and other controllers to be a professional shotbox surface for an increasing amount of different presentation switchers, video playback software and broadcast equipment.
http://bitfocus.io/companion
Other
1.57k stars 499 forks source link

Start as a windows service #2760

Open brianteeman opened 7 months ago

brianteeman commented 7 months ago

Is this a feature relevant to companion itself, and not a module?

Is there an existing issue for this?

Describe the feature

The ability to run companion as a windows service would be great. Then we can start companion automatically with windows and not have to login

Usecases

The remote PC used for companion will regularly reboot and sit at the windows login screen. Any attached surface or comapnion satellite will be unable to work until someone gets to the PC and logs in. (assuming they even know why nothing is working).

Julusian commented 7 months ago

I think it is entirely possible to do this already, with some effort. I'm not sure what we should do on this here, other than perhaps a wiki page describing the process? Do you fancy drafting a guide for setting this up?

I think the process will be to:

It is also worth noting, that this companion will not appear in the tray, but the interface will be accessible in a browser at http://localhost:8000 like normal

brianteeman commented 7 months ago

Thanks - will try that

swamiforlife2 commented 6 months ago

@brianteeman where you able to get this to work as a service in windows?

lfrisk commented 6 months ago

Also interested in if you were able to get this to work.

IMBArator commented 5 months ago

Hey ... i think i found a solution/workaround...

As far as I've read it's not possible to run node as a native windows service. But ...

You can use a wrapper like WinSW (https://github.com/winsw/winsw) to run companion as Service. I used the following steps:

  1. Download and install Companion as usual. Disable companion's Autostart in your user if already enabled.
  2. Create a folder to store the wrapper and the companion config data -> C:\ProgramData\companion
  3. Download Winsw to C:\ProgramData\companion and rename it to companion.exe
  4. Create the winsw config file C:\ProgramData\companion\companion.xml. I've uploaded mine with this Comment.
  5. Start a cmd with admin privileges and cd into C:\ProgramData\companion.
  6. Run companion.exe install ... This now creates the service called companion which can be found in the services.msc.
  7. Now run companion.exe start to start the service. At this point you should be able to open http://127.0.0.1:8000/ with your web browser :)

My companion.xml:

<service>
  <id>companion</id>
  <name>Companion</name>
  <description>Run Bitfocus Companion as Service</description>
  <executable>"c:\program files\companion\resources\node-runtime\node.exe"</executable>
  <arguments>"c:\program files\companion\resources\main.js" "--config-dir" "C:\ProgramData\companion" "--admin-address" "127.0.0.1"</arguments>
</service>

For more info on WinSW have a look at their Readme and the doc folder inside the project.

brianteeman commented 5 months ago

Really sorry about the delay in replying. Life got in the way - these are my notes from doing it using nssm

Download the latest version and extract the contents to a directory of your choice.

Now, your Node.js script should be running as a service on your Windows 11 system. You can manage the service using the "Services" application (services.msc) or other service management tools.

mwb9aa commented 5 months ago

@Julusian, @swamiforlife2, @lfrisk, @brianteeman

I'm not sure if Companion is running as a service, but here are the steps I do to have Companion start with a machine running Windows.

  1. Install Companion as normal.
  2. Uncheck the Run at Login box (to avoid the error Companion is already running).
  3. Change the GUI interface dropdown to All Interfaces 0.0.0.0.
  4. Open Task Scheduler.
  5. Create a Task
    • Choose a task trigger as "At startup". (Choose a delay if you have services or connections that need to run on that machine before starting Companion).
    • Choose to start a program from a location such as "C:\Program Files\Companion\Companion.exe".
    • Modify Conditions or Settings as needed. I suggest checking "Allow task to be run on demand", and "If the running task does not end when requested, force it to stop".
    • After creating the task, modify the General properties to select "Run whether the user is logged on or not. You don't have to use as password unless you would need Companion to access more resources than normal.

Notes: Companion does not show up in the system tray. If you need to change the GUI interface, you will need to stop the Companion task from inside task schedular and start Companion from the app list/program location.