Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
howto:systemd [2018/01/14 13:06] – [See Also] digital manhowto:systemd [2022/06/27 14:03] – [Ubuntu 16.04+] typo nelgin
Line 1: Line 1:
-====== Start Synchronet BBS from Systemd ======+====== Start Synchronet BBS from systemd ======
  
-If you run modern GNU/Linux distributions, you can found [[https://en.wikipedia.org/wiki/Systemd|Systemd]] as init system (like Debian, Fedora and others).+If you run modern GNU/Linux distribution, you will likely discover [[https://en.wikipedia.org/wiki/Systemd|systemd]] is used as the init system (for starting and control system services/daemons).
  
-Instead of use the old /etc/init.d/sbbs.service init script, you can create a systemd services unit file:+In this case, instead of use the old SysV-style /etc/init.d/sbbs.service init script, you use a systemd services unit file: 
 + 
 +Create and edit (or download from [[http://cvs.synchro.net/cgi-bin/viewcvs.cgi/*checkout*/install/systemd/sbbs.service|here]]) the following file (please correct your ExecStart path and User/Group as you need): 
 + 
 +===== Where is My Service File? ===== 
 + 
 +If you are already running Synchronet from systemd but can't remember where the config file is, the following commands will help. 
 + 
 +''systemctl status'', then when viewing the file type ''/sbbs''. Note the service name (probably sbbs.service). ''q'' to quit back to the command line. 
 + 
 +Use that service name to return the path to the config file. Example: ''systemctl show -p FragmentPath sbbs.service''
  
-Create and edit the follow files (please correct your ExecStart path and User/Group as you need): 
  
 ===== Ubuntu 16.04+ ===== ===== Ubuntu 16.04+ =====
-/lib/systemd/system/sbbs.service +''/lib/systemd/system/sbbs.service'' 
-  [Unit]+<file> 
 +[Unit]
   Description=Synchronet BBS service   Description=Synchronet BBS service
   Documentation=man:sbbs   Documentation=man:sbbs
   After=syslog.target network.target   After=syslog.target network.target
      
-  [Service]+[Service]
   Type=forking   Type=forking
   Environment=SBBSROOT=/sbbs SBBSCTRL=/sbbs/ctrl   Environment=SBBSROOT=/sbbs SBBSCTRL=/sbbs/ctrl
 +  # this stops you running out of files
 +  LimitNOFILE=10000
 +  # this enables you to take a good core dump
 +  LimitCORE=infinity
   User=sbbs   User=sbbs
   Group=sbbs   Group=sbbs
   PermissionsStartOnly=true   PermissionsStartOnly=true
-  ExecStartPre=/sbin/setcap 'cap_net_bind_service=+ep' /sbbs/src/sbbs3/gcc.linux.x64.exe.release/sbbs 
   ExecStart=/sbbs/exec/sbbs d   ExecStart=/sbbs/exec/sbbs d
   ExecReload=/bin/kill -HUP $MAINPID   ExecReload=/bin/kill -HUP $MAINPID
Line 26: Line 39:
   RestartSec=30   RestartSec=30
      
-  [Install]+[Install]
   WantedBy=multi-user.target   WantedBy=multi-user.target
 +</file>
  
 Some points in this config: Some points in this config:
Line 33: Line 47:
    * **Type**. If you are to run SBBS in daemonized mode, the main executable will exit after the daemon is called. This could confuse systemd into thinking the process is finished. If you use "Type=forking" you tell systemd that the process you launch will execute another process.    * **Type**. If you are to run SBBS in daemonized mode, the main executable will exit after the daemon is called. This could confuse systemd into thinking the process is finished. If you use "Type=forking" you tell systemd that the process you launch will execute another process.
    * **Environment**. In order to avoid having multiple files, you can embed the variables inside the service file.    * **Environment**. In order to avoid having multiple files, you can embed the variables inside the service file.
-   * **PermissionsStartOnly**. This one tells systemd to execute ExecStartPre as root, but ExecStart as the user and group declared in User,Group. +   * **User/Group**. **Remove these** if you would like sbbs to start as root and then drop privileges to the User & Group configured in your sbbs.ini. Possibly remove **PermissionsStartOnly** and **ExecStartPre** as well, as they would be unnecessary.   If you leave these in, ensure the User/Group settings in sbbs.ini are commented out. 
-   * **ExecStartPre**. For some weird reason, capabilities are frequently lost from the sbbs executable. It is possible to mitigate the effect by running setcap just before the daemon is ran. The binding won't fail anymore using this. Please notice you can't point a symlink here, so modify the architecture directory to the right path (gcc.linux.x64.exe.release or gcc.linux.exe.release).+   * **PermissionsStartOnly**. This one tells systemd to execute ExecStartPre as root, but ExecStart as the user and group declared in User,Group.  Can be removed if you remove the User/Group lines.
    * **ExecStart**. If you don't want to get syslog entries duplicated you will have to run SBBS in daemonized mode, so the "d" parameter is used. Syslog is implicit when daemonized, so there is no need for additional parameters.     * **ExecStart**. If you don't want to get syslog entries duplicated you will have to run SBBS in daemonized mode, so the "d" parameter is used. Syslog is implicit when daemonized, so there is no need for additional parameters. 
    * **RestartSec**. It's advisable to wait some secs before attempting restarting in case of failure, just to give some time for binding release.    * **RestartSec**. It's advisable to wait some secs before attempting restarting in case of failure, just to give some time for binding release.
Line 53: Line 67:
       Docs: man:sbbs       Docs: man:sbbs
    Process: 12364 ExecStart=/sbbs/exec/sbbs d (code=exited, status=0/SUCCESS)    Process: 12364 ExecStart=/sbbs/exec/sbbs d (code=exited, status=0/SUCCESS)
-   Process: 12356 ExecStartPre=/sbin/setcap cap_net_bind_service=+ep /sbbs/src/sbbs3/gcc.linux.x64.exe.release/sbbs (code=exited, status 
   Main PID: 12374 (sbbs)   Main PID: 12374 (sbbs)
      Tasks: 11      Tasks: 11
Line 67: Line 80:
   Dec 11 20:24:03 HISPAMSX sbbs[1226]: term Node 1 thread terminated (0 node threads remain, 71 clients served)   Dec 11 20:24:03 HISPAMSX sbbs[1226]: term Node 1 thread terminated (0 node threads remain, 71 clients served)
  
 +**NOTE**:\\
 +If you're running any kind of recent (last 2yrs+) systemd, to avoid the use of ''[[howto:linux_non-root|setcap]]'' to run 'sbbs' as a non-root user, just put this line in the ''[Service]'' section of your ''sbbs.service'' file:  ''**AmbientCapabilities=CAP_NET_BIND_SERVICE**''
 +===== Monitoring with Byobu (Tmux backend) =====
 +You can have a text mode dashboard for monitoring and configuring your BBS realtime by using Byobu with Tmux or GNU Screen backends. If you are using the Tmux backend. The following configuration splits your screen in three panes: one for SBBS log, other for UMONITOR and a last one for SCFG. Please note that this configuration assumes SBBSCTRL variable is set and that access permissions to the needed files are set for the current user.
  
 +Create the file ''$BYOBU_CONFIG_DIR/windows.tmux.sbbs'' with the following contents:
 +
 +  new-session sbbs ;
 +  new-window -n sbbs tail -n 50 -f /var/log/sbbs.log ;
 +  split-window -h /sbbs/exec/umonitor ;
 +  split-window -t 1 -v /sbbs/exec/scfg ;
 +  set-option mouse on
 +
 +And then run: ''user@localhost:~$ BYOBU_WINDOWS=sbbs byobu''
 +
 +If you want this to be your default environment when you log at your Synchronet server, then write the configuration to the ''$BYOBU_CONFIG_DIR/windows.tmux'' file instead of ''$BYOBU_CONFIG_DIR/windows.tmux.sbbs''
 +
 +The following screenshot shows the result:
 +
 +{{:monitor:sbbs_monitor_byobu.png?200|}}
 +
 +If are using also **binkd** for FidoNet, this configuration will split the dashboard in 4 panes:
 +
 +  new-session sbbs ;
 +  new-window -n sbbs tail -n 50 -f /var/log/sbbs.log ;
 +  split-window -p 50 -h /sbbs/exec/umonitor ;
 +  split-window -t 0 -p 20 -v tail -f /var/log/binkd.log ;
 +  split-window -t 1 -v /sbbs/exec/scfg ;
 +  set-option mouse on
 +
 +{{:monitor:sbbs_monitor_byobu_4pane.png?200|}}
 ===== Debian & CentOS 7 =====  ===== Debian & CentOS 7 ===== 
  
Line 91: Line 134:
  
  
-Finally, you must execute //systemd daemon-reload// for tell systemd te reload the unit file+Finally, you must execute //systemd daemon-reload// for tell systemd to reload the unit file
  
 Test your setup: Test your setup:
Line 141: Line 184:
  
 ===== Recommended Tweaks to the Service Section === ===== Recommended Tweaks to the Service Section ===
-Add these to the ''[Service]'' section:+Add these to the ''[Service]'' section of your service's config file:
  
 To increase the open file limit: To increase the open file limit:
-  LimitNOFILE=10000+<file sbbs.service> 
 +LimitNOFILE=10000 
 +</file>
  
 To allow core file generation (for crash/segfault debugging: To allow core file generation (for crash/segfault debugging:
-  LimitCORE=infinity+<file sbbs.service> 
 +LimitCORE=infinity 
 +</file>
  
 ===== See Also ===== ===== See Also =====
   * [[:howto:|howto index]]   * [[:howto:|howto index]]
 +  * [[https://synchronetbbs.org/index.php/downloads]] - Alternate startup script that uses "screen" rather than tmux and restarts the server if it should crash.
 {{tag>linux systemd}} {{tag>linux systemd}}
  
howto/systemd.txt · Last modified: 2023/04/07 12:28 by digital man
Back to top
CC Attribution 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0