问题
I have two problems running freeswitch from systemd :
EDIT 2 - I have moved the slow start up question to here (Freeswitch pauses on check_ip at boot on centos 7.1) as although they may be related it's probably good as a standalone.
EDIT - I have noticed something else. Look at these next lines captured from the terminal output when running it from there. The gap is 4 minutes but it has been around 10 minutes before. I noticed it because I was trying to find out why port 8021 was taking several minutes to accept the fs_cli connection. Why does this happen? Never happened to me before and I've installed loads of FS boxes. This does the same thing on both 1.7 & todays 1.6.
2015-10-23 12:57:35.280984 [DEBUG] switch_scheduler.c:249 Added task 1 heartbeat (core) to run at 1445601455 2015-10-23 12:57:35.281046 [DEBUG] switch_scheduler.c:249 Added task 2 check_ip (core) to run at 1445601455 2015-10-23 13:01:31.100892 [NOTICE] switch_core.c:1386 Created ip list rfc6598.auto default (deny)
- I sometimes get double processes started. Here is my status line after such an occurrence :
# systemctl status freeswitch -l freeswitch.service - freeswitch Loaded: loaded (/etc/systemd/system/multi-user.target.wants/freeswitch.service) Active: activating (start) since Fri 2015-10-23 01:31:53 BST; 18s ago Main PID: 2571 (code=exited, status=0/SUCCESS); : 2742 (freeswitch) CGroup: /system.slice/freeswitch.service ├─usr/bin/freeswitch -ncwait -core -db /dev/shm -log /usr/local/freeswitch/log -conf /usr/local/freeswitch/conf -run /usr/local/freeswitch/run └─usr/bin/freeswitch -ncwait -core -db /dev/shm -log /usr/local/freeswitch/log -conf /usr/local/freeswitch/conf -run /usr/local/freeswitch/run Oct 23 01:31:53 fswitch-1 systemd[1]: Starting freeswitch... Oct 23 01:31:53 fswitch-1 freeswitch[2742]: 2743 Backgrounding.
and there are two processes running.
- The PID file is sometimes not written fast enough for the systemd process to pick it up, but by the time I see this (no matter how fast I run the command) it's always there by the time I do :
Oct 23 02:00:26 arribacom-sbc-1 systemd[1]: PID file /usr/local/freeswitch/run/freeswitch.pid not readable (yet?) after start.
Now, in (2) everything seems to work ok, and I can shut down the freeswitch process using
systemctl stop freeswitch
without any issues, but in (1) it just doesn't seem to do anything.
I'm wondering if the two are related, and that freeswitch is reporting back to systemd that the program is running before it actually is. Then systemd is either starting up another process or (sometimes) not.
Can anyone offer any pointers? I have tried to mail the freeswitch users list but despite being registered I simply cannot get any emails to appear on the list (but that's another problem).
* Update * If I remove the -ncwait it seems to improve the double process starting but I still get the can't read PID warning, so I'm still sure there's an issue present, possibly around timing(?).
I'm on Centos 7.1, & my freeswitch version is
FreeSWITCH Version 1.7.0+git~20151021T165609Z~9fee9bc613~64bit (git 9fee9bc 2015-10-21 16:56:09Z 64bit)
and here's my freeswitch.service file (some things have been commented out until I understand what they are doing and any side effects they may have) :
[Unit] Description=freeswitch After=syslog.target network.target # [Service] Type=forking PIDFile=/usr/local/freeswitch/run/freeswitch.pid PermissionsStartOnly=true ExecStart=/usr/bin/freeswitch -nc -core -db /dev/shm -log /usr/local/freeswitch/log -conf /u ExecReload=/usr/bin/kill -HUP $MAINPID #ExecStop=/usr/bin/freeswitch -stop TimeoutSec=120s # WorkingDirectory=/usr/bin User=freeswitch Group=freeswitch LimitCORE=infinity LimitNOFILE=999999 LimitNPROC=60000 LimitSTACK=245760 LimitRTPRIO=infinity LimitRTTIME=7000000 #IOSchedulingClass=realtime #IOSchedulingPriority=2 #CPUSchedulingPolicy=rr #CPUSchedulingPriority=89 #UMask=0007 # [Install] WantedBy=multi-user.target
回答1:
In the current master branch, take the two files from debian/
directory:
freeswitch-systemd.freeswitch.service
-- should go as /lib/systemd/system/freeswitch.service
freeswitch-systemd.freeswitch.tmpfile
-- should go as /usr/lib/tmpfiles.d/freeswitch.conf
You probably need to adapt the paths, or build FreeSWITCH to use standard Debian paths.
来源:https://stackoverflow.com/questions/33298818/inconsistent-systemd-startup-of-freeswitch