Synchronet v3.19b-Win32 (install) has been released (Jan-2022).

You can donate to the Synchronet project using PayPal.

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
howto:systemd [2016/12/11 09:31]
Karloch Added Ubuntu 16.04 systemd startup with enhanced options
howto:systemd [2022/05/07 20:25]
Andre systemd shouldn't be capitalized. Added a section for people to find their existing service file. Minor formatting fix to "tweaks" section.
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
   Environment=SBBSROOT=/​sbbs SBBSCTRL=/​sbbs/​ctrl   Environment=SBBSROOT=/​sbbs SBBSCTRL=/​sbbs/​ctrl
   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 ​nd syslog+
   ExecReload=/​bin/​kill -HUP $MAINPID   ExecReload=/​bin/​kill -HUP $MAINPID
-  StandardInput=null 
-  StandardOutput=null 
   Restart=on-failure   Restart=on-failure
   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:
    * **After**. If you are using syslog with sbbs, so it is nice to put that requirement before systemd tries to launch sbbs.    * **After**. If you are using syslog with sbbs, so it is nice to put that requirement before systemd tries to launch sbbs.
 +   * **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 asroot, 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 inensure ​the User/Group settings in sbbs.ini are commented out
-   * **ExecStartPre**. ​For some weird reasoncapabilities are frequently lost from the sbbs executableIt is possible to mitigate the effect by running setcap just before the daemon is ran. The binding won't fail anymore using this+   * **PermissionsStartOnly**. This one tells systemd to execute ExecStartPre as rootbut ExecStart as the user and group declared in User,Group Can be removed if you remove ​the User/Group lines
-   * **ExecStart**. It's actually more useful to run sbbs without daemonize under systemd, in contrast ​to the SysV wayso the "​nd"​ parameter is useful. However this will prevent using the syslogso the parameter is addedPlease 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)+   * **ExecStart**. If you don't want to get syslog entries duplicated you will have to run SBBS in daemonized modeso the "d" ​parameter is usedSyslog is implicit when daemonized, so there is no need for additional parameters
-   * **StandardInput/​StandardOutput**. For some reasonsystemd was displaying control characters from the sbbs logging, making the logs annoying to read and systemd reporting ​"blob data"​. ​It looks like it had something to do with the I/O treatment systemd does to the logging. Disabling it led sbbs logging playing nice with systemd journal, so null to them.+
    * **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.
  
 Installation instructions:​ Installation instructions:​
-  - Put this file in /​lib/​systemd/​system/ +  -Modify the environment variables to match your SBBS setup 
-  - Run "​systemctl enable sbbs"​ +  -Modify User and Group. If you run this as root you don't need the ExecStartPre line. 
-  - sbbs will be executed at startup and systemd will follow his execution health.+  -Modify the ExecStart and ExecStartPre paths to match your Synchronet setup. 
 +  -Place ​this file in the correct location. For Ubuntu 16.04 you should place it in /​lib/​systemd/​system 
 +  -Enable the service with "​systemctl enable sbbs"​ 
 +  -To run the service without restarting "​systemctl start sbbs"
  
 Running //systemctl status sbbs// will show: Running //systemctl status sbbs// will show:
  
   ● sbbs.service - Synchronet BBS service   ● sbbs.service - Synchronet BBS service
-     Loaded: loaded (/​lib/​systemd/​system/​sbbs.service;​ enabled; vendor preset: enabled) +    ​Loaded: loaded (/​lib/​systemd/​system/​sbbs.service;​ enabled; vendor preset: enabled) 
-     ​Active: active (running) since Sun 2016-12-11 16:41:21 CET; 1h 42min ago +    Active: active (running) since Thu 2016-12-15 20:20:43 CET; 16s ago 
-       ​Docs: man:sbbs +      Docs: man:sbbs 
-   Main PID: 1226 (sbbs) +   Process: 12364 ExecStart=/​sbbs/​exec/​sbbs d (code=exited,​ status=0/​SUCCESS) 
-      Tasks: ​19 +  ​Main PID: 12374 (sbbs) 
-     ​Memory: ​94.0M +     ​Tasks: ​11 
-        CPU: 1min 38.596s +    Memory: ​30.1M 
-     ​CGroup: /​system.slice/​sbbs.service +       ​CPU: 223ms 
-             ​└─1226 /​sbbs/​exec/​sbbs ​nd syslog+    CGroup: /​system.slice/​sbbs.service 
 +            └─12374 /​sbbs/​exec/​sbbs ​d
   ​   ​
-  Dec 11 18:23:25 HISPAMSX sbbs[1226]: term Node 1 Telnet ​ ------- [----------] +  Dec 15 20:23:25 HISPAMSX sbbs[1226]: term Node 1 Telnet ​ ------- [----------] 
-  Dec 11 18:23:25 HISPAMSX sbbs[1226]: 12/11 18:23:25 term Node 1 Telnet ​ -------- [----------] +  Dec 15 20:23:31 HISPAMSX sbbs[1226]: term Node 1 Terminal not detected, reducing inactivity hang-up timeout to 75 seconds 
-  Dec 11 18:23:31 HISPAMSX sbbs[1226]: term Node 1 Terminal not detected, reducing inactivity hang-up timeout to 75 seconds +  Dec 15 20:23:36 HISPAMSX sbbs[1226]: term Node 1 Unknown User '​Enable'​ 
-  Dec 11 18:23:31 HISPAMSX sbbs[1226]: 12/11 18:23:31 term Node 1 Terminal not detected, reducing inactivity hang-up timeout to 75 seconds +  Dec 15 20:24:02 HISPAMSX sbbs[1226]: term Node 1 disconnected 
-  Dec 11 18:23:36 HISPAMSX sbbs[1226]: term Node 1 Unknown User '​Enable'​ +  Dec 11 20:24:03 HISPAMSX sbbs[1226]: term Node 1 thread terminated (0 node threads remain, 71 clients served) 
-  Dec 11 18:23:36 HISPAMSX sbbs[1226]: 12/11 18:23:36 term Node 1 Unknown User '​Enable'​ + 
-  Dec 11 18:24:02 HISPAMSX sbbs[1226]: term Node 1 disconnected +**NOTE**:\\ 
-  Dec 11 18:24:02 HISPAMSX sbbs[1226]: 12/11 18:24:02 term Node 1 disconnected +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**''​ 
-  Dec 11 18:24:03 HISPAMSX sbbs[1226]: term Node 1 thread terminated (0 node threads remain, 71 clients served) +===== Monitoring with Byobu (Tmux backend) ===== 
-  Dec 11 18:24:03 HISPAMSX ​sbbs[1226]: 12/11 18:24:03 term Node thread terminated (0 node threads remain71 clients served) ​+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 -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 serverthen 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 ===== 
 /​etc/​default/​sbbs /​etc/​default/​sbbs
   SBBSCTRL=/​sbbs/​ctrl   SBBSCTRL=/​sbbs/​ctrl
Line 91: Line 130:
  
  
-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 139: Line 178:
  
 {{:​howto:​sbbs_tmux.png?​200|}} {{:​howto:​sbbs_tmux.png?​200|}}
 +
 +===== Recommended Tweaks to the Service Section ===
 +Add these to the ''​[Service]''​ section of your service'​s config file:
 +
 +To increase the open file limit:
 +<file sbbs.service>​
 +LimitNOFILE=10000
 +</​file>​
 +
 +To allow core file generation (for crash/​segfault debugging:
 +<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>}}+{{tag>linux systemd}}
  

In Other Languages