Since I’m a mere User rather than a Programmer I amazed myself at being able to successfully compile and install a working webRTC server earlier today! The instructions at https://nextcloud.com/webrtc/ (although a bit outdated now) were invaluable. However, where I am having difficulties is properly creating and installing a systemd script to get the server running upon system startup.
I’ve followed certain other links but they led to instructions which were written with the assumption that the reader would have the requisite skills to fill-in the missing instruction blanks. This has left me scratching my head and coming to the Community, hoping for a hand-out! With this in mind, I humbly ask: Could someone please post detailed instructions on how to do the above? May I further ask that in so doing, would you please assume that you’re writing said instructions for your computer-illiterate granny?
…“Then you just need to write a simple systemd unit around”…
Thanks for your input, Jiri. Alas, unless Granny codes in between bouts of knitting and making strawberry jam, I think that she’ll be floundering in such a sea of appreciated but much-too-general instructions
Since running the webrtc server is such a fundamental aspect of this great app, it would be nice if the spreedme devs could complete their otherwise excellent instructions with a nice little “systemd unit” example with full directions…
Simply move it into the /etc/systemd/system/ directory and run systemctl enable spreed-webrtc.service
Make sure to update /usr/sbin/spreed-webrtc-server to the location of your Spreed WebRTC binary and also create a /etc/default/spreed-webrtc file based on this content: https://github.com/spreedbox-packaging/spreed-webrtc-debian/blob/ubuntu/trusty/debian/spreed-webrtc.default
(Again, make sure to update the paths wherever applicable.
I tried to follow your steps but don’t get the service to run. I did the following:
/etc/systemd/system/spreed.service
[Unit]
Description=Spreed WebRTC server
After=network.target
[Service]
Type=simple
EnvironmentFile=/etc/default/spreed
# TODO: These values should come from the EnvironmentFile.
Environment=GOMAXPROCS=1
LimitNOFILE=1024
User=spreed
Group=www-data
PermissionsStartOnly=true
ExecStart=/usr/sbin/spreed -c ${WEBRTC_CONF} -l ${WEBRTC_LOG} ${WEBRTC_ARGS}
Restart=on-failure
[Install]
WantedBy=multi-user.target
/etc/default/spreed
# Defaults for spreed-webrtc initscripts
WEBRTC_USER='spreed'
WEBRTC_GROUP='www-data'
WEBRTC_CONF='/etc/spreed/server.conf'
WEBRTC_LOG='/var/log/spreed.log'
WEBRTC_ARGS=""
WEBRTC_RUN_DIR='/var/run/spreed/'
WEBRTC_PID="${WEBRTC_RUN_DIR}/server.pid"
WEBRTC_GOMAXPROCS=1
WEBRTC_NOFILE=1024
ln -s /etc/spreed/spreed-webrtc-server /usr/sbin/spreed
service spreed start
But the syslog gives me the following error around several others, telling me that the service start failed:
systemd[21615]: Failed at step USER spawning /usr/sbin/spreed: No such process
It works, if I just start /usr/sbin/spreed in the terminal. Does the link/file in /usr/sbin/ have to look different than a simple symlink? Also I shortened some file/folder names and therefore the links/arguments. But as starting the server in terminal works fine, that should not be the problem?
Hmm, after managing to create the user, give him the necessary rights, I got the server at least to the point, that it already starts logging. But sadly it logs the following error:
Unable to find client. Path correct and compiled css?
Any idea what the problem is? I am impressed how much to tinker, to just realize an autorun :D. Maybe I should stay at running the server as my own user in screen .
I’m sorry, I was a bit too hasty. root needs to point to the www folder of your Spreed WebRTC installation. So root = /usr/share/spreed-webrtc-server/www is just an example if your installation resides at that path.
Okay got it now by pointing “root” to my “/etc/spreed” path, so the base path where the spreed server was extracted to. Thank you for your help. I will write some step-by-step guide about how to configure the autorun with creating the spreed user for it etc. for less experienced linux users .
Actually which files/folders in the “root” directory need to be owned/readable/executable etc. by the spreed user? For security reasons I would just chown what is really necessary and leave as much as possible owned by root. I mean I don’t know how much is really possible through a system user without pw like this, but for in case ;).
Only the installed spreed-webrtc-server binary needs to be executable.
Nothing needs to be writable (haven’t tried it, should work).
All files need to be readable.
To make it simpler/cleaner I removed the following from environment file, as they are not used and therefore {$WEBRTC_ARGS} from the exec command of service file or course.
I am wondering which run directory is used by default, as there is non given in your “ExecStart” above?
I tried to chown the server directory back to root:root, chmod -R 744 everything and the \bin\spreed-webrtc-server to 755. But got permissions error. Then I 755ed also the \spreed-webrtc-server (binary in main directory), thought this might be executed by the one inside \bin also or something. But still permissions error. I also thought the folders itself /spreed-webrtc-master and /bin might be necessary to be executable, and at least the error moved to my spreed.log (instead of syslog), giving the “Unable to find client. Path correct and compiled css?” error again. Finally I chmod -R 755 the whole server directory again and it worked.
=> So I guess at least there are some more files beside the binaries that need to be executable.
€€: I also had a look at the service and environment files. I guess it is common beautiful way to use environment files to the service values. Also it is possible to adjust them there without the “systemctl daemon-reload” hint. As every value given in the service file is also listed as default, I guess everything could be changed to ${WEBRTC_…} right? "Environment=1" lets the EnvironmentFile be used?
So to make it more simple on the other hand, it would be also possible to not use and erase the environment file and just write out the config + log files directly inside the service file, right?
Sorry for asking so much question, I just try to understand how all of this is working .