Skip to main content
Topic: Sunshine :: Gamestream Server for Linux Hosts (Read 4537 times) previous topic - next topic
0 Members and 2 Guests are viewing this topic.

Sunshine :: Gamestream Server for Linux Hosts

I currently have an Artix OpenRC (xfce) vm with an nVIDIA GRID K520 attached to it. The drivers are installed, and the DE still works (unlike last time). However, I can't seem to get sunshine running as a service. I used a PKGBUILD to build and install the package, and then created an openrc init script for the service. However, attempting to start the service returns the following:

sunshined         | * Initialising sunshined... ...
sunshined         |[2021:08:20:00:43:00]: Fatal: Could not open x11 display for keyboard
sunshined         | * start-stop-daemon: failed to start `/usr/bin/sunshi [ !! ]
sunshined         | * ERROR: sunshined failed to start


I'm not sure what has gone wrong, and could use some pointers on where to go next. If you need to see the init script, logs, or anything else, just say so and I'll do my best to grab it for you.

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #1
As it states, it cannot connect to x11. This means X11 environment DISPLAY is not preserved when script calls sunshi. Most likely the best way to prevent this message is to start this program manually
ARMtix

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #2
As it states, it cannot connect to x11. This means X11 environment DISPLAY is not preserved when script calls sunshi. Most likely the best way to prevent this message is to start this program manually

I've tried autostarting it and manually starting it, with the same results. I wish it was that :(

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #3
I've tried autostarting it and manually starting it, with the same results. I wish it was that :(

Same error message? Are you running a Wayland session?

EDIT:

- Starting it as a system service, get the same error message as OP.
- Starting it from the terminal, I get: "could not create sunshine mouse, no such file or directory"
- running sudo modprobe uinput makes the program start successfully.


 

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #5
Same error message? Are you running a Wayland session?

EDIT:

- Starting it as a system service, get the same error message as OP.
- Starting it from the terminal, I get: "could not create sunshine mouse, no such file or directory"
- running sudo modprobe uinput makes the program start successfully.



That't the exact same thing that happens for me, which confuses the crap outta me.



Sorry for taking so long to get back to you. I work weekends, and haven't had the time to fire up the VM yet. Will do once I get home today.



Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #8
Yea, the service could be more clear that it requires the uinput kernel module.

As you alluded to recently, I was able to make sure this kernel module was enabled (one-off) with

Code: [Select]
sudo modprobe uinput

However, I had no change in success with starting sunshine via the startup script. I can post the startup script here for inspection if you want.

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #9
As you alluded to recently, I was able to make sure this kernel module was enabled (one-off) with
Code: [Select]
sudo modprobe uinput
However, I had no change in success with starting sunshine via the startup script. I can post the startup script here for inspection if you want.
Instruct your system to load the module at boot:
Code: [Select]
# echo uinput >/etc/modules-load.d/uinput.conf

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #10
Unfortunately, I'm still running into the same error. The only way I can ever get sunshine to start is manually, with sudo (which was true before and after loading uinput at boot time). I'll post both the Terminal output and a copy of the openrc init script, in case I screwed up in writing the script.

Terminal output:
Code: [Select]
➜  ~ sudo rc-service sunshined start
[sudo] password for tophatproductions115:
sunshined         | * Initialising sunshined... ...
sunshined         |[output_name] -- [0]
sunshined         |[upnp] -- [enabled]
sunshined         |[nv_coder] -- [auto]
sunshined         |[resolutions] -- [[
sunshined         |    352x240,
sunshined         |    480x360,
sunshined         |    858x480,
sunshined         |    1280x720,
sunshined         |    1920x1080,
sunshined         |    2560x1080,
sunshined         |    3440x1440,
sunshined         |    1920x1200,
sunshined         |    3860x2160,
sunshined         |    3840x1600
sunshined         |]]
sunshined         |[min_log_level] -- [2]
sunshined         |[origin_web_ui_allowed] -- [lan]
sunshined         |[origin_pin_allowed] -- [pc]
sunshined         |[hevc_mode] -- [0]
sunshined         |[amd_rc] -- [auto]
sunshined         |[nv_preset] -- [default]
sunshined         |[nv_rc] -- [auto]
sunshined         |[amd_quality] -- [default]
sunshined         |[fps] -- [[10,30,60,90,120]]
sunshined         |[2021:08:29:00:09:30]: Fatal: Could not open x11 display for keyboard
sunshined         | * start-stop-daemon: failed to start `/usr/bin/sunshi [ !! ]
sunshined         | * ERROR: sunshined failed to start


sunshined:
Code: [Select]
#!/sbin/openrc-run


# For a true tutorial on how to write decent OpenRC init scripts, goto:
# https://github.com/OpenRC/openrc/blob/master/service-script-guide.md


name="sunshined"
description="Sunshine Gamestream Server for Moonlight"
command="/usr/bin/sunshine"


command_args="-p ${pidfile}"
pidfile="/var/run/sunshined.pid"

# The previous two lines assume that sunshine is a 'a well-behaved daemon that backgrounds itself and writes its own PID file by default'.

# If sunshine needs to have its user or group changed for it, the following line can be used.

command_user="tophatproductions115:tophatproductions115"


start() {
    ebegin "Initialising sunshined..."
    # Be sure to set the X display - if you have more than one X display, set it to the non-local-session.
    DISPLAY=:1
    start-stop-daemon --start --exec /usr/bin/sunshine
    eend $?
}

stop() {
    ebegin "Terminating sunshined..."
    start-stop-daemon --stop --exec /usr/bin/sunshine
    eend $?
}


Please let me know if I made an obvious mistake. This is my first attempt at writing one, and I'm pretty sure I stumbled somewhere in this case...

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #11
Your $DISPLAY is :0.0, why did you specify :1 in the script?

This can load uinput on demand, instead of the previous "at boot" solution:
Code: [Select]
start_pre() {
    einfo "Loading uinput module"
    /usr/bin/modprobe uinput 2>&1
}

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #12
The VM that this is running in has multiple displays. I'm trying to target the one powered by an nVIDIA GRID card, and not the VMware vsga one. I'm probably going about it completely wrong though. I'll try display 0 as you've stated.

That start_pre() function has me feeling pretty dumb, because I didn't think of it from the start :| Thanks for the tip.

Here is the github for the sunshine project, in case anything else looks strange:

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #13
Your $DISPLAY is :0.0, why did you specify :1 in the script?

This can load uinput on demand, instead of the previous "at boot" solution:
Code: [Select]
start_pre() {
    einfo "Loading uinput module"
    /usr/bin/modprobe uinput 2>&1
}


I made the changes you suggested, plus a few others. Still having some difficulty making Sunshine behave with OpenRC. Here are the script, and the terminal output:


Code: [Select]
#!/sbin/openrc-run


# An amateur attempt at an OpenRC script for Sunshine
# https://github.com/loki-47-6F-64/sunshine

# For a true tutorial on how to write decent OpenRC init scripts, goto:
# https://github.com/OpenRC/openrc/blob/master/service-script-guide.md


# The service is given a name, a description, and a specified binary location.

name="sunshined"
description="Sunshine Gamestream Server for Moonlight"
command="/usr/bin/sunshine"

# RC_SVCNAME is a variable that should contain the name of the service.
# If this does not work, can replace it with the word sunshine instead.

command_args="-p ${pidfile}"
pidfile="/var/run/${RC_SVCNAME}.pid"

# The previous two lines assume that sunshine is a 'a well-behaved daemon that backgrounds itself and writes its own PID file by default'.

command_background=true

# But this line is here because we know better - it needs to be sent to the background.

# If sunshine needs to have its user or group changed for it, the following line can be used.

command_user="tophatproductions115:input"

# Perhaps I should use the default user group instead (tophatproductions115) ?


depend() {
    # Wait for the display manager, so we can actually have a graphical session to work with
    need lightdm
}

# Before we begin, there is one last thing to attend to...

start_pre() {
    einfo "Loading uinput module"
    /usr/bin/modprobe uinput 2>&1
}


# The start-stop  commands, for when it's time to roll.


start() {
    ebegin "Initialising sunshined..."
    # Be sure to set the X display - if you have more than one X display, set it to the non-local-session.
    DISPLAY=:0
    start-stop-daemon --start --exec /usr/bin/sunshine
    eend $?
}

stop() {
    ebegin "Terminating sunshined..."
    start-stop-daemon --stop --exec /usr/bin/sunshine
    eend $?
}


# In many cases, you shouldn't have to roll your own start, stop, and status functions.
# If you need yours to do something that the standard implementation does not do, feel free to write your own.


Code: [Select]
➜  ~ sudo rc-service sunshined start
sunshined         | * Caching service dependencies ...                                        [ ok ]
sunshined         | * Loading uinput module
sunshined         | * Initialising sunshined... ...
sunshined         |[output_name] -- [0]
sunshined         |[upnp] -- [enabled]
sunshined         |[nv_coder] -- [auto]
sunshined         |[resolutions] -- [[
sunshined         |    352x240,
sunshined         |    480x360,
sunshined         |    858x480,
sunshined         |    1280x720,
sunshined         |    1920x1080,
sunshined         |    2560x1080,
sunshined         |    3440x1440,
sunshined         |    1920x1200,
sunshined         |    3860x2160,
sunshined         |    3840x1600
sunshined         |]]
sunshined         |[min_log_level] -- [2]
sunshined         |[origin_web_ui_allowed] -- [lan]
sunshined         |[origin_pin_allowed] -- [pc]
sunshined         |[hevc_mode] -- [0]
sunshined         |[amd_rc] -- [auto]
sunshined         |[nv_preset] -- [default]
sunshined         |[nv_rc] -- [auto]
sunshined         |[amd_quality] -- [default]
sunshined         |[fps] -- [[10,30,60,90,120]]
sunshined         |[2021:08:31:21:31:01]: Fatal: Could not open x11 display for keyboard
sunshined         | * start-stop-daemon: failed to start `/usr/bin/sunshine'                  [ !! ]
sunshined         | * ERROR: sunshined failed to start


I'll need to do some more research on this. Something is preventing the service from starting successfully. May have to just kick VMware's video adapter from the equation, so that the only one left standing is the nVIDIA GRID card...

Re: Sunshine :: Gamestream Server for Linux Hosts

Reply #14
I've tried at least 4 or 5 variations on xorg.conf, and can't get a virtual screen/monitor made for the GRID K520. Without this, I doubt that I'll be able to get Sunshine started properly. I may need to have this thread hibernated indefinitely...