Please, please FreeBSD gurus, I need your help! šŸ™

It works, and I guess itā€™s good enough for now.

EDIT: Correction, itā€™s exhibiting the behavior of ā€œno internetā€ again. Now Iā€™m trying to backtrack how it worked the first time.


I thought custom rc.d scripts were fairly intuitive, but apparently thereā€™s more under-the-hood of FreeBSD that I donā€™t understand.

Interestingly, I think this might be the application itself (slskd). The reason I suspect this is because if I use the same rc.d script, but change the command to a simple ping -c 4 vps.slsknet.org, it pings the server without issue.

Likewise, other rc.d scripts for ports built against FreeBSD connect to the internet just fine, and they use similar syntax and layout.

They are intuitive once you understand how they work. I struggled for a long time trying to figure out the ā€œfailed to set user environmentā€ issue.

I finally had to just go read the manual, which was extremely helpful.

Do you mind sharing how you installed the app? I could try to run it myself.

I followed the instructions from here.

Keep in mind that his ā€œstepsā€ are not entirely accurate, as he mixes plain English ā€œinā€ with explicit commands of ā€œcdā€.

Just notice when to ā€œcorrectā€ some steps. Otherwise, youā€™ll find that some steps will say ā€œfile/folder not foundā€.

Essentially, at the very end youā€™ll have a directory named freebsd-x64 under the ā€œdistā€ folder. This contains the executables, libraries, and web files. It can be renamed to slskd and copied to /opt or wherever you prefer. (I like to use /opt for applications built/installed that do no exist as official ports or packages.)

Youā€™ll obviously need git and npm, so his first command might as well be:

  • pkg install git npm dotnet sqlite3
Contents of my /opt/slskd after everything is finished

config
etc
libe_sqlite3.so ā†’ /usr/local/lib/libsqlite3.so
LICENSE
slskd
wwwroot

Thereā€™s a YAML config file that doesnā€™t exist, but it can be copied from config/slskd.example.yml and copied into the userā€™s local directory at $HOME/.local/share/slskd/slskd.yml

You absolutely need to uncomment and edit the following lines to create a user account to connect to the Soulseek Network. As long as the username is not in use, itā€™ll automatically login as ā€œthisā€ account. So for testing purposes, you can make it very random. Iā€™ll provide an example that you can change accordingly.

You must uncomment those three lines, and only edit username and password. The ā€œspacingā€ must be kept intact, so only remove the # symbol with a single DEL or BACKSPACE stroke.

 soulseek:
#   address: vps.slsknet.org
#   port: 2271
   username: RandomHuman1234
   password: 1234WXYZ

Itā€™s up to you if you want to change some defaults in the slskd.yml config file. (The default username/password for the web GUI is slskd/slskd, and the default HTTP port is 5030.)

The moment you login, youā€™ll see if itā€™s connected to the Soulseek Network. (The logs will also provide additional information, which are accessible in the web GUI ā†’ System ā†’ Logs)

Iā€™d recommend, of course, running the executable manually to confirm it connects before trying the rc.d method.


When all is said and done, even if this can work as an rc.d service with full internet access running as root, I still will not run it as root, and would rather keep it as a non-root user. (I used pw to create the user soulseek before I built this application.)

Failed to create CoreCLR, HRESULT: 0x8007FF02

When running the ā€œdotnetā€ build command.

Mlock mlock :yawning_face:

Have you tried an alternate client?

This one is the ports tree.

Iā€™m not getting it to work using the RC script. The only way it seems to work is by using the root user.

1 Like

Thatā€™s a graphical desktop application.


Sadly, it seems thereā€™s ā€œsomethingā€ about this application (which never got first-class FreeBSD support) that doesnā€™t play nice when running it as a service with a non-root user.

So itā€™s either RC script + run as root, or just use @Jailerā€™s method of adding it to the userā€™s crontab, and setting it to run ā€œ@rebootā€.

I think itā€™s more of an issue with the way service scripts run. Because it seems to run fine when you login with that user and then run the command.

1 Like

Thatā€™s a client. ā€¦So this thing youā€™re trying to compile and run is a server then.

The idea I was going on was that they may not have implemented the daemon code properly (-i.e. maybe they fork the child, sit and wait, but they donā€™t handle the signals all that well. *shrug* Iā€™m just working through an idea). Which .net did you install (7,8,9) BTW (maybe there is something there with the version and mlock)?

Have you tried:
https://man.freebsd.org/cgi/man.cgi?query=daemonize&apropos=0&sektion=1&manpath=FreeBSD+13.2-RELEASE+and+Ports&arch=default&format=html

EDIT: I just read the man page and daemonize may not work any better but Iā€™m still thinking itā€™s worth a quick shot.

If the host operating system provides the daemon(3) library routine, daemonize will use it. Otherwise, daemonize uses its own version of daemon(3).

I canā€™t even get the script working as rootā€¦
It still says failed to resolveā€¦

The only way it works is if you invoke the command directly from the command line.

Make a wrapper script to restart the server every ten seconds (not sure how well something like that will work with this app but, just an idea). ā€¦?

NOTE: a cron job could take the place of this wrapper script too so take this with a grain of salt. However, I suggested the wrapper script because, the wrapper script could check the PID file to see if the server is still running instead of just blindly starting every ten seconds but Iā€™m not very confidant in the developers daemon so there is a good chance the PID file doesnā€™t get closedā€¦

/usr/local/etc/rc.d/slskd.sh:

#!/bin/sh
if [ -x /opt/slskd/slskd_wrapper ] ; then
    echo -n " slskd"
    /opt/slskd/slskd_wrapper &
fi

/opt/slskd/slskd_wrapper:

#!/bin/sh

: ${slskd_user:="soulseek"}
: ${slskd_config:="/home/${slskd_user}/.local/share/slskd"}

while true ; do
    /opt/slskd/slskd --app-dir=${slskd_config}
    sleep 10
done

I quite possibly make a mistake on the wrapper script / arguments so, please look them over.

Iā€™d like to see the answer to this though. Maybe you could ask on the FreeBSD forums?

You mean as the root user, but via the rc.d script?

Thereā€™s got to be something in the internals that doesnā€™t place nice with FreeBSDā€™s RC.


I might have missed the earlier context to this, but why restart slskd every 10 seconds?

On a Linux-based system (in this case Arch Linux), a packager can create the ā€œserviceā€ for slskd very simply:

Check out this service file from the AUR package.

slskd.service for Arch Linux systems (systemd service)
[Unit]
Description=Slskd Service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
User=slskd
Group=slskd
SyslogIdentifier=slskd
WorkingDirectory=/var/lib/slskd/
ExecStart=/usr/lib/slskd/slskd
Restart=on-failure

[Install]
WantedBy=multi-user.target

It runs in the background as the user ā€œslskdā€ by launching the executable /usr/lib/slskd/slskd

Can be controlled with systemctl commands, such as systemctl stop slskd

Thereā€™s really not much to itā€¦


Thatā€™s what I was aiming for with a FreeBSD RC script. And while it ā€œworkedā€, it had no internet access. (Unless you launch it without using RC.)

So this tells me that itā€™s not enough to just ā€œportā€ something to FreeBSD or allow it to be ā€œbuiltā€ for FreeBSD, but other modifications likely need to be patched into the code to make it truly work 100% with FreeBSD. Reading the GitHub, this isnā€™t the only time that the developers donā€™t seem too concerned with making something work with the same parity on FreeBSD as it does with Linux (and ironically, macOS and Windows sometimes.)

I say this because, for all intents and purposes, a FreeBSD package maintainer could technically create a port/pkg for slskd, just like an AUR packager did so for Arch Linux. But how would the FreeBSD package maintainer include it as a service, which the AUR packager managed to do so successfully? Such a person would be in the same boat as us.


EDIT: I will say that using the (not as ideal) ā€œcronā€ method is working as expected. The application runs as a non-root user (ā€œsoulseekā€), and I have successfully searched for and downloaded some files from the Soulseek Network over a WireGuard VPN connection.

That service file is for making a daemon from C# code in Linux. Itā€™s more about laziness or ignorance from the developer. ā€“ Daemons are written differently than normal programs. Not to get into the weeds but a program is essentially a signal handlerā€“signals are generated from events and those signals are delivered to the program and it knows what to do about those; daemons have another level of signal handling and that server/app/program doesnā€™t have that code in it. That service file is essentially the linux version of ā€œdaemonā€ so the developer doesnā€™t have to (to know?) write all that signal handling, forking, etc. daemons need.

2 Likes

I donā€™t run jails. I have a Debianb VM in TrueNAS that runs Portainer which in turn handles all of the apps Iā€™d have jailed back in Core. Never had an issue. Perhaps a different approach is the salvation you seek.

Hell will freeze over before @winnielinnie will leave core for scale xD

1 Like

Iā€™m not going to commit to the overhead of virtualization / VMs just to run native software that can run directly from a jail. I want my CPU and RAM to be free to any and all processes (including ZFSā€™s ARC), without putting anything to the side for a VM.

EDIT: Youā€™ll notice that slskd ā€œworksā€ in a Core/FreeBSD jail. The only caveat is that it cannot be launched as a daemon with a custom rc.d script. (It will run just fineā€¦ but not connect to the internet.) So for now, I created a crontab entry that automatically starts it when the jail starts. Thanks to @Jailer.

Core? Jails. SCALE? Iā€™m looking at Incus or whatever iXsystems settles on for legit, fully-supported ā€œLinux jailsā€. And I do mean fully-supported, where it has the same parity as jails under Core: full, untethered root filesystems with complete network stacks, as if each jail is its own mini server on the local network. (I plan to create/maintain a handful of ā€œArch Linuxā€ jails if/when the time comes, since I will have access to the latest upstream releases of software, plus the massive and underrated ā€œAURā€.)

Ever since the days of FreeNAS 0.7 up until now, Iā€™ve never ran a VM on my NAS server. Never had to, and probably never will.

The forecast shows hell freezing over some time in the year 2026ā€¦ :neutral_face:

Boring is best.

1 Like