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 revisionBoth sides next revision
docs:guide-user:services:voip:freeswitch [2018/09/09 08:39] – [Hotplug] micmac1docs:guide-user:services:voip:freeswitch [2018/11/20 09:44] – [freeswitch-stable init configuration] better warning about write wear and added database storage option bobafetthotmail
Line 7: Line 7:
 </WRAP> </WRAP>
  
-===== freeswitch-stable init command line switches =====+===== freeswitch-stable init configuration =====
  
-In ''/etc/default/freeswitch'' you can change the command line switches that are used when starting FreeSWITCH. E.g. you can set which user FreeSWITCH should switch to and the directories to use for recordings and logs.+The file ''/etc/config/freeswitch'' contains the general on/off switch - FreeSWITCH is disabled by default. Here you can also change the command line switches that are used when starting FreeSWITCH. E.g. you can set which user to switch to and the directories for recordings and logs etc.
  
-The file also contains the line ''ENABLE_FREESWITCH="yes"'', which is commented out by default. If the variable ''ENABLE_FREESWITCH'' is not set to ''yes'', the init script will not start FreeSWITCH.+<WRAP round important> 
 +**WARNING:** FreeSWITCH writes to its databases constantly. Constant writes will quickly kill your device's integrated flash memory. It's recommended to keep the databases on external storage (see [[docs:guide-user:storage:usb-drives|Using storage devices]]).\\ 
 + 
 +If that is not possible they can also be kept in the device's RAM (working memory), on a //tmpfs// filesystem (''/tmp'' is mounted as a //tmpfs// file system on OpenWrt devices). RAM memory is not subject to constant writing wear like flash memory.\\ 
 +The downside of the //tmpfs// approach is that the databases will be lost when the device loses power or is restarted, also the RAM used by these databases will decrease the amount of available RAM of the system by a few MB. Please consider your options and requirements. 
 +</WRAP>  
 + 
 +Last but not least, you can select whether the output streams (//STDOUT// and //STDERR//) that are sent to the init process (''procd'')shall be forwarded to the system logger. Defaults to yes for both.
  
 ===== freeswitch-stable packages ===== ===== freeswitch-stable packages =====
Line 18: Line 25:
  
  
-FreeSWITCH has a multitude of modules. OpenWrt typically runs on hardware that is somewhat restricted, i.e. memory, storage and processing power are limited. Luckily only a few packages are needed for basic functionality (depending on what you want it to do). Here is a list of some modules that you might be interested in:+FreeSWITCH has a multitude of modules. OpenWrt typically runs on hardware that is somewhat restricted, i.e. memory, storage and processing power are limited. Luckily only a few packages are needed for basic functionality (depending on what you want it to do). Here is a list of modules you might be interested in:
  
   * [[https://freeswitch.org/confluence/display/FREESWITCH/mod_commands|freeswitch-stable-mod-commands]]: various API commands, for instance ''fsctl''   * [[https://freeswitch.org/confluence/display/FREESWITCH/mod_commands|freeswitch-stable-mod-commands]]: various API commands, for instance ''fsctl''
Line 47: Line 54:
 ==== Utilities ==== ==== Utilities ====
  
-There are also a number of utilities available. Lets just mention the one that is probably the most important:+There are also a number of utilities available. Let'just mention the one that is probably the most important:
  
   * [[https://freeswitch.org/confluence/display/FREESWITCH/Command-Line+Interface+fs_cli|freeswitch-stable-util-fs-cli]]: allows CLI access to a FreeSWITCH server, either local or remote (uses the event socket interface mentioned above)   * [[https://freeswitch.org/confluence/display/FREESWITCH/Command-Line+Interface+fs_cli|freeswitch-stable-util-fs-cli]]: allows CLI access to a FreeSWITCH server, either local or remote (uses the event socket interface mentioned above)
Line 61: Line 68:
 Any of these will install the corresponding sample configuration to ''/usr/share/freeswitch/examples''. Any of these will install the corresponding sample configuration to ''/usr/share/freeswitch/examples''.
  
-==== Hotplug ====+===== Hotplug ====
 + 
 +The //freeswitch-stable// package includes a hotplug script. You can set a hotplug interface in ''/etc/config/freeswitch'' to enable it. 
 + 
 +Note: It may be advisable to disable the init autostart, to avoid FreeSWITCH beeing started twice when booting: 
 + 
 +<code> 
 +/etc/init.d/freeswitch disable 
 +</code> 
 + 
 +The hotplug script can check the following extra conditions: 
 + 
 +  * a device (perhaps a USB stick) is connected at a given mount point (for instance ''/mnt/usb''
 +  * the system clock is accurate (needs ''ntpd'' to be installed)
  
-//freeswitch-stable-misc-hotplug// contains a hotplug script. It will start FreeSWITCH when a user-selectable interface comes upThe script can be influenced by editing ''/etc/default/freeswitch''. It is advisable to disable the FreeSWITCH autostart with ''/etc/init.d/freeswitch disable'' to avoid FreeSWITCH beeing started twice when booting.+If you add any of these conditions the hotplug script will only start FreeSWITCH if the condition is metYou can also specify the timeout after which it considers a condition failed (defaults to 60 seconds).
  
-Here is what is visible in the OpenWrt log when the the hotplug script gets called:+Below a log excerpt from the hotplug script in action:
  
-''Sun Sep  9 10:06:17 2018 user.notice freeswitch-hotplug: stopping freeswitch +<code> 
-Sun Sep  9 10:06:28 2018 user.notice freeswitch-hotplug: freeswitch stopped +Sat Nov 17 11:24:43 2018 user.notice freeswitch-hotplug: /mnt/usb mounted 
-Sun Sep  9 10:06:28 2018 user.notice freeswitch-hotplug: /mnt/usb mounted +Sat Nov 17 11:24:43 2018 user.notice freeswitch-hotplug: ntpd stratum 16 
-Sun Sep  9 10:06:28 2018 user.notice freeswitch-hotplug: ntpd stratum 3 +Sat Nov 17 11:24:43 2018 user.notice freeswitch-hotplug: system time not in sync yet, timeout in 60 s 
-Sun Sep  9 10:06:28 2018 user.notice freeswitch-hotplug: ntpd to system time offset +/- ms +Sat Nov 17 11:24:48 2018 user.notice freeswitch-hotplug: ntpd stratum 16 
-Sun Sep  9 10:06:28 2018 user.notice freeswitch-hotplug: system time in sync +Sat Nov 17 11:24:48 2018 user.notice freeswitch-hotplug: system time not in sync yet, timeout in 55 s 
-Sun Sep  9 10:06:29 2018 user.notice freeswitch-hotplug: started freeswitch due to "ifup wan" event''+Sat Nov 17 11:24:53 2018 user.notice freeswitch-hotplug: ntpd stratum 3 
 +Sat Nov 17 11:24:53 2018 user.notice freeswitch-hotplug: ntpd to system time offset +/- ms 
 +Sat Nov 17 11:24:53 2018 user.notice freeswitch-hotplug: system time in sync 
 +Sat Nov 17 11:24:54 2018 user.notice freeswitch-hotplug: started freeswitch due to "ifup wan" event 
 +</code>
  
-FreeSWITCH was already running when the WAN interface went up (so this could have been DSL connection going down and then up again).+Both extra conditions were configured. A device was already mounted at ''/mnt/usb''. The system time was initially not accurate, so the hotplug script waited bit before starting FreeSWITCH.
  
-The first thing that happens is that FreeSWITCH is stopped if it is already running. Then the script checks if a device is mounted at /mnt/usb (if you don't specify a mount point this will be skipped, obviously). Next it tests if the system time is in sync (if you enabled the ntpd check). 
  
-Finally FreeSWITCH is started again. Be aware that restarting FreeSWITCH can take a few minutes, because it will go through its databases and check different states, e.g. of calls and registrations. Check with ''top''. While it starts up it uses all available CPU cycles (100% if it can). Once it successfully completed its initialization the CPU usage goes down to normal levels. 
  • Last modified: 2022/05/31 20:33
  • by micmac1