Bug 212237 - audio/teamspeak3-server: not starting under FreeBSD 11
Summary: audio/teamspeak3-server: not starting under FreeBSD 11
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Nikolai Lifanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-08-29 13:11 UTC by Jonathan Price
Modified: 2017-01-15 01:39 UTC (History)
4 users (show)

See Also:
Ultima1252: maintainer-feedback+


Attachments
teamspeak3-server.diff (448 bytes, patch)
2016-11-08 18:57 UTC, Ultima
Ultima1252: maintainer-approval+
Details | Diff
teamspeak3-server.diff (459 bytes, patch)
2017-01-10 03:20 UTC, Ultima
Ultima1252: maintainer-approval+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Price 2016-08-29 13:11:37 UTC
I have been trying to get teamspeak3-server running on FreeBSD 11, and below are my findings so far. Please note that I HAVE managed to get it running, just not with the correct paths / user, so the issue should be resolvable by the port.

I initially tried running the port without modification. This produced the following in /var/log/teamspeak:
2016-08-29 12:23:15.560913|ERROR   |DatabaseQuery |   |db_connect() failed unable to open database file
2016-08-29 12:23:15.560949|CRITICAL|ServerLibPriv |   |Server() DatabaseError out of memory

I then edited the "command_args" line of /usr/local/etc/rc.d/teamspeak, and removed the "-u teamspeak" section, meaning that the daemon was being started as root. I then found that this was creating the files that should be in /var/db/teamspeak directly in /.

Next, I ran the command "/usr/local/libexec/ts3server" directly, and found that it writes the database files to my pwd, wherever that happens to be. Looking at the rc file, this is known behaviour, as it includes the line "teamspeak_chdir=$db_dir", which should set the pwd to /var/db/teamspeak when the script is executed. It appears that this line is being ignored. 

I am continuing to look into this, but somebody who better understands the rc system may quickly spot the issue.
Comment 1 Jonathan Price 2016-08-29 14:17:47 UTC
After further searching I eventually found a relevant post from the mailing lists back in March:

https://lists.freebsd.org/pipermail/freebsd-current/2016-March/060240.html

Having tested the sample rc file they provided, I am also receiving the result "/". This suggests that it is due to a change in the RC system from 10.x to 11.x. 

I do not yet have a workaround for the script, but manually running the whole daemon command will allow you to start it, and it can be stopped from the RC file still.
Comment 2 Ultima 2016-08-29 19:02:17 UTC
 Hello Jonathan, thanks for the report, I looked into this sometime ago and found the issue is with the new login_class limits. I'm still working out a fix.

 Currently my workaround is to comment out line 1075 of rc.subr. The issue is that the default class given to services is the daemon class, and the daemon class has a 128M limit on memory. Teamspeak uses around 180 so fails to startup.

 Another fix, and the currently recommended over commenting, increasing max limit for daemon class in login.conf. Don't forget to run cap_mkdb after editing the config.
Comment 3 Ultima 2016-08-29 19:04:36 UTC
Also see bug #211629
Comment 4 Jonathan Price 2016-08-29 19:18:08 UTC
(In reply to Ultima from comment #2)

Hello, and thanks for the quick reply.

I believe i'm having some trouble implementing your fix in login.conf. I have made the following modification:
Before:
daemon:\
        :memorylocked=128M:\

After:
daemon:\
        :memorylocked=512M:\

I then ran cap_mkdb login.conf, and attempted to start the daemon. At this point I received the same error in the TeamSpeak logs.

Could you please confirm that I am implementing your suggestion correctly?
Comment 5 Ultima 2016-08-29 19:25:41 UTC
 Apologies, I failed to mention a restart is required after changing login.conf. I'm unable to test right now. 2 week vacation just ended and short on time atm.
Comment 6 Ultima 2016-08-31 20:51:15 UTC
 After investigating more, it seems that using limits(at least will a class) on teamspeak at all will cause this error. The only course of action that i'v found that will successfully start teamspeak if to comment out line 1075 in /etc/rc.subr. Still investigating the root cause. Will reply again once it is found. Sorry about my previous comments about the memory limit. The pieces aligned, but aren't connected.
Comment 7 Ultima 2016-09-08 18:08:21 UTC
 This issue is with ordering in the /etc/rc.subr file. When the rc script runs, it will run the limits command on cd then run prog without limits, running limits on the cd command causes cd to fail which is causing the program itself to fail to start.

This problem cannot be fixed within the port because it is a base issue. I have opened a bug for the rc.subr with an attached fix. bug #212493
Comment 8 Ultima 2016-11-08 18:57:37 UTC
Created attachment 176797 [details]
teamspeak3-server.diff

Simple patch to allow teamspeak to build on 11 again. Do not commit until bug #212493 has been committed. Thanks.

portlint -AC:
WARN: Makefile: possible use of absolute pathname "/var/db/teamspeak".
WARN: Makefile: possible use of absolute pathname "/var/log/teamspeak".
WARN: Makefile: for new port, make $FreeBSD$ tag in comment section empty, to make SVN happy.
WARN: Makefile: new ports should not set PORTEPOCH.
WARN: Makefile: using hyphen in PORTNAME. consider using PKGNAMEPREFIX and/or PKGNAMESUFFIX.
WARN: Makefile: "RESTRICTED" found. do not forget to update ports/LEGAL.
0 fatal errors and 6 warnings found.

poudriere bulk -tC:
12amd64: success
12i386: success
110amd64: success
110i386: success
103amd64: success
103i386: success
93amd64: is marked as broken on FreeBSD 9.3: No longer starts on 9.x
93i386: is marked as broken on FreeBSD 9.3: No longer starts on 9.x
Comment 9 Ultima 2017-01-10 03:20:19 UTC
Created attachment 178686 [details]
teamspeak3-server.diff

 This patch is to lift the broken status on 11-STABLE as of r310010, it will now start again. If r310010 is MFS, will alter as needed.

portlint:
WARN: Makefile: possible use of absolute pathname "/var/db/teamspeak".
WARN: Makefile: possible use of absolute pathname "/var/log/teamspeak".
WARN: Makefile: for new port, make $FreeBSD$ tag in comment section empty, to make SVN happy.
WARN: Makefile: new ports should not set PORTEPOCH.
WARN: Makefile: using hyphen in PORTNAME. consider using PKGNAMEPREFIX and/or PKGNAMESUFFIX.
WARN: Makefile: "RESTRICTED" found. do not forget to update ports/LEGAL.
WARN: /usr/ports/audio/teamspeak3-server/distinfo: [1]: TIMESTAMP is over 30 days old
WARN: Consider to set DEVELOPER=yes in /etc/make.conf
0 fatal errors and 8 warnings found.

poudriere bulk -tC:
12amd64: success https://poudriere.ultimasbox.com/data/12amd64-test/2017-01-09_22h03m53s/logs/teamspeak3-server-3.0.13.6,1.log
12i386: success https://poudriere.ultimasbox.com/data/12i386-test/2017-01-09_21h45m25s/logs/teamspeak3-server-3.0.13.6,1.log
110amd64: is marked as broken on FreeBSD 11.0: Will not start on 11, Bug 212493
110i386: is marked as broken on FreeBSD 11.0: Will not start on 11, Bug 212493
103amd64: success https://poudriere.ultimasbox.com/data/103amd64-test/2017-01-09_21h45m03s/logs/teamspeak3-server-3.0.13.6,1.log
103i386: success https://poudriere.ultimasbox.com/data/103i386-test/2017-01-09_21h45m14s/logs/teamspeak3-server-3.0.13.6,1.log
Comment 10 commit-hook freebsd_committer 2017-01-14 23:32:16 UTC
A commit references this bug:

Author: lifanov
Date: Sat Jan 14 23:31:30 UTC 2017
New revision: 431501
URL: https://svnweb.freebsd.org/changeset/ports/431501

Log:
  audio/teamspeak3-server: unbreak on 11-STABLE

  PR:		212237
  Submitted by:	ultima1252@gmail.com (maintainer)
  Reported by:	Jonathan Price <freebsd@jonathanprice.org>
  Reviewed by:	matthew
  Approved by:	matthew (mentor)
  Differential Revision:	https://reviews.freebsd.org/D9170

Changes:
  head/audio/teamspeak3-server/Makefile
Comment 11 Nikolai Lifanov freebsd_committer 2017-01-14 23:34:48 UTC
I committed an alternative fix. The one provided didn't work (it has to happen after bsd.options.mk and also it checked FreeBSD version in two places, which wasn't ideal).

Thanks!
Comment 12 Ultima 2017-01-15 01:39:07 UTC
(In reply to Nikolai Lifanov from comment #11)
Just read the differential, surprised there were issues. I tested the if statement several times with in poudriere with varying situations and they all worked as expected. Even if the if statement returned true on a lower major version, the var selected would only work on 11 so it wouldn't matter. But as long as it works I am happy.

OSSYS is def a good check to add as well I will remember this!