Systemd Bitlbee service script

Again good spot, missed that myself.Cheers.

Hello,

After compiling again with the parameters, this new systemd unit was created in /lib/systemd/system/bitlbee.service:

[Unit]
Description=BitlBee IRC/IM gateway

[Service]
ExecStart=/usr/local/sbin/bitlbee -F -n
KillMode=process

[Install]
WantedBy=multi-user.target

It is still all the same. I tried adding the Type=forking field and no changes. The PID process still runs on inetd mode -I.
Also, the service now seems to hang on “activating” when I start it manually:

  • bitlbee.service - bitlbee irc/im gateway
    Loaded: loaded (/etc/systemd/system/bitlbee.service; enabled)
    Active: activating (start) since Tue 2017-04-25 19:55:50 CST; 1min 18s ago
    Control: 1018 (bitlbee)
    CGroup: /system.slice/bitlbee.service
    `-1018 /usr/local/sbin/bitlbee -F -n

Apr 25 19:55:50 osmc2 systemd[1]: Stopping bitlbee irc/im gateway…
Apr 25 19:55:50 osmc2 systemd[1]: Starting bitlbee irc/im gateway…

Here’s are the most recent logs: https://pastebin.com/MWYngaFH

Hi Georgie,

Can you please run: sudo systemctl disable bitlebee and sudo reboot 0.

Are you by any chance still able to see bitlbee in inetd mode -I, I just want to make sure nothing else is starting bitlbee on Startup? (There may still be something in init.d or rc.local.)

Also As I said before I’m not familiar with this app, can you please advise what the flags do; -I, -F and -n?

Thanks Tom.

P.S

@georgie

/etc/bitlbee/bitlbee.conf:


[settings]
RunMode = Inetd

inetd mode -I, may be coming from your .conf file, it may be worth changing this to:

RunMode = Daemon

or

RunMode = ForkDaemon

https://www.watters.ws/mediawiki/index.php/Example_Bitlbee_Config

Then update /lib/systemd/system/bitlbee.service to:

[Unit]
Description=BitlBee IRC/IM gateway
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/sbin/bitlbee -F -c /etc/bitlbee/bitlbee.conf
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
sudo systemctl restart bitlbee

If it starts as it should, try a restart.

Thanks Tom.

Hi Tom,

From the man pages:

-I     Run in inetd(8) mode. This is the default setting, you usually don't have to specify this option.

-F     Run  in  ForkDaemon  mode. This is similar to ordinary daemon mode, but every client gets its own process. Easier to set up than inetd mode, and without the possible stability issues.

-n     Only useful when running in daemon mode. This option prevents BitlBee from forking into the background.

I ran sudo systemctl disable bitlebee and sudo reboot 0 and the service still starts with the -I flag.

@Tom_Doyle
Yes, I was already running RunMode = ForkDaemon in my …/bitlbee.conf file.

Hi Georgie,

Do you still have /etc/init.d/bitlbee?

If so try removing this and reboot. (or sudo mv /etc/init.d/bitlbee /home/osmc/bitlbee)

Is the Service still starting on startup?

Thanks Tom.

This line caught my eye in post #22.

Check if that is a symbolic link to /lib/systemd/system/bitlbee.service. And anyway, the link should be in /etc/systemd/system/multi-user.target.wants if the service is enabled.

Hi Tom,

No, that’s the first thing I removed from init.d before configuring the systemd unit.

It is working now, but I didn’t do anything differently. The bitlbee systemd unit still does not load on boot, if I start it manually the service it never starts and the shell hangs unless I exit out (ctrl+c).
The process is still running with the -I flag, but somehow it is now loading my /etc/bitlbee/bitlbee.conf file.

@Tom_Doyle
Is there any other way I can check if another system is starting up that process?

Hi @dillthedog,

I reenabled the service just in case:

sudo systemctl reenable bitlbee.service

Removed symlink /etc/systemd/system/multi-user.target.wants/bitlbee.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/bitlbee.service to /etc/systemd/system/bitlbee.service.

The service hangs, but according to htop it is running. Status returns:

* bitlbee.service - bitlbee irc/im gateway
   Loaded: loaded (/etc/systemd/system/bitlbee.service; enabled)
   Active: activating (start) since Tue 2017-04-25 22:08:31 CST; 12s ago
  Control: 1088 (bitlbee)
   CGroup: /system.slice/bitlbee.service
           `-1088 /usr/local/sbin/bitlbee -F -n

So is the unit’s service file in /lib/systemd/system or /etc/systemd/system?

@dillthedog
It is in /lib/systemd/system/, I corrected it after I read your post.

But we see that systemctl enable creates a:

symlink from /etc/systemd/system/multi-user.target.wants/bitlbee.service to /etc/systemd/system/bitlbee.service

but the (real) service file isn’t there, it’s in /lib/systemd/system. Please check what’s actually in these directories.

Hi,

When you compiled the later version, did you uninstall the repository package first?

apt-get remove bitlbee

Thanks Tom.

Hi guys,

I really have no idea why I placed the unit under /etc/systemd/system, probably misread a tutorial.
Path /etc/systemd/system no longer contains anything related to bitlbee.
Anyways, I removed the symlink in the above folder and re-enabled the unit.

I am back to where I started, I can manually start the unit but it doesn’t load on boot.
I had previously removed any previous packages from the repository package and I am pretty sure I’m only running my compiled version.

The path /lib/systemd/system shows 2 files:

bitlbee.service
bitlbee@.service

Upon inspection, the bitlbee@.service shows this:

[Unit]
Description=BitlBee Per-Connection Server

[Service]
ExecStart=/usr/local/sbin/bitlbee -I
StandardInput=socket
User=bitlbee

This is the process that starts whenever I boot.
What’s the difference between the 2 files?

@dillthedog
Also:
sudo systemctl reenable bitlbee

Removed symlink /etc/systemd/system/multi-user.target.wants/bitlbee.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/bitlbee.service to /lib/systemd/system/bitlbee.service.

Edit1: an @. static file is a unit that’s not enabled. Maybe I can delete it?
https://www.freedesktop.org/software/systemd/man/systemctl.html

How do you manually run it and what do systemctl status and ps show? Please also run grab-logs -J after a fresh restart and a manual run of bitlbee (ie one log only).

How do you know that?. What’s the output from systemctl | grep bitlbee after a reboot and after a manual start?

The bitlbee@.service file is a template file for tunning multiple instances of bitlbee. So you should see something like bitlbee@something.service running. It’s a bit unusual in that it uses no arguments but I see that ssh does something similar, so it’s not necessarily incorrect. I’ll need to read-up on this.

Regarding your edit, you can’t enable template files. Don’t delete it.

Edit: added grab-logs -J

This is how I manually start the service:

systemctl start bitlbee.service

After a fresh reboot:

http://paste.osmc.io/omuxuxobad

systemctl status bitlbee.service

  • bitlbee.service - BitlBee IRC/IM gateway
    Loaded: loaded (/lib/systemd/system/bitlbee.service; enabled)
    Active: inactive (dead)

systemctl | grep bitlbee:

bitlbee@0-127.0.0.1:6667-127.0.0.1:48342.service loaded active running BitlBee Per-Connection Server (127.0.0.1:48342)
system-bitlbee.slice loaded active active system-bitlbee.slice
bitlbee.socket loaded active listening bitlbee.socket

ps -aux | grep bitlbee

bitlbee 529 0.8 3.3 16472 12244 ? Ss 16:23 0:06 /usr/local/sbin/bitlbee -I

After manually starting the service:

http://paste.osmc.io/babunezaxo

systemctl status bitlbee.service

* bitlbee.service - BitlBee IRC/IM gateway
   Loaded: loaded (/lib/systemd/system/bitlbee.service; enabled)
   Active: active (running) since Wed 2017-04-26 16:38:10 CST; 6s ago
  Process: 1034 ExecStart=/usr/local/sbin/bitlbee -F -c /etc/bitlbee/bitlbee.conf (code=exited, status=0/SUCCESS)
 Main PID: 1036 (bitlbee)
   CGroup: /system.slice/bitlbee.service
           `-1036 /usr/local/sbin/bitlbee -F -c /etc/bitlbee/bitlbee.conf

sudo systemctl | grep bitlbee

bitlbee.service loaded active running BitlBee IRC/IM gateway
bitlbee@0-127.0.0.1:6667-127.0.0.1:48342.service loaded active running BitlBee Per-Connection Server (127.0.0.1:48342)
system-bitlbee.slice loaded active active system-bitlbee.slice

sudo ps -aux | grep bitlbee

bitlbee 529 0.5 3.3 16472 12244 ? Ss 16:23 0:06 /usr/local/sbin/bitlbee -I
bitlbee 1036 0.0 1.0 11044 3936 ? Ss 16:38 0:00 /usr/local/sbin/bitlbee -F -c /etc/bitlbee/bitlbee.conf

Thanks. I’ll get back to you later today.

Hi Georgie,

does /etc/default/bitlbee exist on your osmc?

If so can you post its contents?

Thanks Tom.

Guys, this is getting way too complicated.

I literaly had a spare 10 minutes and I built and installed v3.5.1 of bitlbee and, guess what, it just runs. No complications, just works out of the box.

Unless there’s something extra super-duper special that you need to do, it should work just fine if you build it yourself for v3.5.1.

I’m curious. How exactly did you get to where you are now?

Here is my version happily running after a reboot:

osmc@osmc:~/bitlbee-3.5.1$ systemctl status bitlbee.service
● bitlbee.service - LSB: Start and stop BitlBee IRC to other chat networks gateway
   Loaded: loaded (/etc/init.d/bitlbee)
   Active: active (running) since Wed 2017-04-26 12:36:48 CEST; 1min 19s ago
   CGroup: /system.slice/bitlbee.service
           └─2984 /usr/sbin/bitlbee -p 6667 -P /var/run/bitlbee.pid -F
1 Like

Hi @Tom_Doyle,

My /etc/default/bitlbee file is empty:

## This file is deprecated and no longer used. ## Please edit /etc/bitlbee/bitlbee.conf instead

And @dillthedog is right, this got complicated for no reason. I am trying to run some additional facebook plugins with Bitlbee, but I needed the newest available build for it to work. So I had to recompile a build and for some reason that broke my original init.d script that I was using before without problems.

I’ll start a fresh osmc copy now. Thank you both.

I was starting to think this would be the way to proceed, I hope it all works correctly.