{"action":"created","issue":{"url":"https://api.github.com/repos/FRRouting/frr/issues/2902","repository_url":"https://api.github.com/repos/FRRouting/frr","labels_url":"https://api.github.com/repos/FRRouting/frr/issues/2902/labels{/name}","comments_url":"https://api.github.com/repos/FRRouting/frr/issues/2902/comments","events_url":"https://api.github.com/repos/FRRouting/frr/issues/2902/events","html_url":"https://github.com/FRRouting/frr/pull/2902","id":353821548,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEwNzY4MDE5","number":2902,"title":"To avoid running of the second instance of a FRR daemon, if it is alr…","user":{"login":"bisdhdh","id":7814685,"node_id":"MDQ6VXNlcjc4MTQ2ODU=","avatar_url":"https://avatars2.githubusercontent.com/u/7814685?v=4","gravatar_id":"","url":"https://api.github.com/users/bisdhdh","html_url":"https://github.com/bisdhdh","followers_url":"https://api.github.com/users/bisdhdh/followers","following_url":"https://api.github.com/users/bisdhdh/following{/other_user}","gists_url":"https://api.github.com/users/bisdhdh/gists{/gist_id}","starred_url":"https://api.github.com/users/bisdhdh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bisdhdh/subscriptions","organizations_url":"https://api.github.com/users/bisdhdh/orgs","repos_url":"https://api.github.com/users/bisdhdh/repos","events_url":"https://api.github.com/users/bisdhdh/events{/privacy}","received_events_url":"https://api.github.com/users/bisdhdh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":10,"created_at":"2018-08-24T15:06:20Z","updated_at":"2018-08-24T17:51:00Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/FRRouting/frr/pulls/2902","html_url":"https://github.com/FRRouting/frr/pull/2902","diff_url":"https://github.com/FRRouting/frr/pull/2902.diff","patch_url":"https://github.com/FRRouting/frr/pull/2902.patch"},"body":"To avoid running of the second instance of a FRR daemon, if it is already running.\t\r\nFRRouting#2680\t\r\n\r\nSolution :\t\r\nThe following procedures would be performed :\t\r\nVerify if the pid file for each daemon is present or not. If the file is not present, that means the daemon is getting instantiated for the first time. So let it go ahead. If the file is present proceed to point ‘2’.\t\r\nTry fetching the properties of the pid file\t\r\nIf it has RW lock, that means one instance of this the daemon is already running. So stop moving ahead and do exit() else let it go ahead.\t\r\nPlease note all above procedure happen at the initial state of daemon’s instantiation, much before it starts any session with other process/allocates resources etc.. and this verification do not have any impact of any operations done later, if the verification succeeds.\t\r\n\r\nI had covered these daemons :\t\r\nBgpd\t\r\nEigrpd\t\r\nIsisd\t\r\nLdpd\t\r\nNhrpd\t\r\nOspf6d\t\r\nPrbd\t\r\nOspfd\t\r\nRipd\t\r\nRipngd\t\r\nZebrad\t\r\npimd\t\r\nDaemons that are not covered are :\t\r\nbabled\t\r\nsharpd\t\r\nwatchfrrd\t\r\nTest Cases run :-\t\r\nroot@dev:/var/run/frr# ls -lrt *.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 zebra.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 bgpd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 ripd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 ripngd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 ospfd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 ospf6d.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 isisd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 pimd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 ldpd.pid\t\r\n-rw-r--r-- 1 root frr 6 Aug 8 02:04 nhrpd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 eigrpd.pid\t\r\n-rw-r--r-- 1 frr frr 6 Aug 8 02:04 pbrd.pid\t\r\n-rw-r--r-- 1 root root 6 Aug 8 02:04 watchfrr.pid\t\r\nroot@dev:/var/run/frr# lsof *.pid\t\r\nCOMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME\t\r\nzebra 13138 frr 11uW REG 0,16 6 241 zebra.pid\t\r\nbgpd 13145 frr 11uW REG 0,16 6 634 bgpd.pid\t\r\nripd 13156 frr 7uW REG 0,16 6 636 ripd.pid\t\r\nripngd 13164 frr 7uW REG 0,16 6 638 ripngd.pid\t\r\nospfd 13172 frr 8uW REG 0,16 6 640 ospfd.pid\t\r\nospf6d 13180 frr 8uW REG 0,16 6 642 ospf6d.pid\t\r\nisisd 13188 frr 7uW REG 0,16 6 645 isisd.pid\t\r\npimd 13196 frr 8uW REG 0,16 6 667 pimd.pid\t\r\nldpd 13207 frr 11uW REG 0,16 6 678 ldpd.pid\t\r\nnhrpd 13215 frr 10uW REG 0,16 6 681 nhrpd.pid\t\r\neigrpd 13224 frr 7uW REG 0,16 6 683 eigrpd.pid\t\r\npbrd 13232 frr 7uW REG 0,16 6 685 pbrd.pid\t\r\nwatchfrr 13240 root 7uW REG 0,16 6 689 watchfrr.pid\t\r\nroot@dev:/var/run/frr# ps -elf | grep frr\t\r\nWarning: /boot/System.map-4.4.36-nn3-server not parseable as a System.map\t\r\n0 T root 2068 2065 0 80 0 - 6280 - 01:49 pts/2 00:00:00 editor /root/frr/.git/COMMIT_EDITMSG\t\r\n5 S frr 13138 1 0 75 -5 - 275138 ffffff 02:04 ? 00:00:00 /usr/lib/frr/zebra -s 90000000 --daemon -A 127.0.0.1\t\r\n5 S frr 13145 1 0 75 -5 - 49529 ffffff 02:04 ? 00:00:00 /usr/lib/frr/bgpd --daemon -A 127.0.0.1\t\r\n5 S frr 13156 1 0 75 -5 - 11781 - 02:04 ? 00:00:00 /usr/lib/frr/ripd --daemon -A 127.0.0.1\t\r\n5 S frr 13164 1 0 75 -5 - 11744 - 02:04 ? 00:00:00 /usr/lib/frr/ripngd --daemon -A ::1\t\r\n5 S frr 13172 1 0 75 -5 - 12036 - 02:04 ? 00:00:00 /usr/lib/frr/ospfd --daemon -A 127.0.0.1\t\r\n5 S frr 13180 1 0 75 -5 - 11882 - 02:04 ? 00:00:00 /usr/lib/frr/ospf6d --daemon -A ::1\t\r\n5 S frr 13188 1 0 75 -5 - 11846 - 02:04 ? 00:00:00 /usr/lib/frr/isisd --daemon -A 127.0.0.1\t\r\n5 S frr 13196 1 0 75 -5 - 11959 - 02:04 ? 00:00:00 /usr/lib/frr/pimd --daemon -A 127.0.0.1\t\r\n4 S frr 13205 1 0 75 -5 - 11201 - 02:04 ? 00:00:00 /usr/lib/frr/ldpd -L\t\r\n4 S frr 13206 1 0 75 -5 - 11238 - 02:04 ? 00:00:00 /usr/lib/frr/ldpd -E\t\r\n5 S frr 13207 1 0 75 -5 - 11957 - 02:04 ? 00:00:00 /usr/lib/frr/ldpd --daemon -A 127.0.0.1\t\r\n5 S frr 13215 1 0 75 -5 - 12382 - 02:04 ? 00:00:00 /usr/lib/frr/nhrpd --daemon -A 127.0.0.1\t\r\n5 S frr 13224 1 0 75 -5 - 11783 - 02:04 ? 00:00:00 /usr/lib/frr/eigrpd --daemon -A 127.0.0.1\t\r\n5 S frr 13232 1 0 75 -5 - 11701 - 02:04 ? 00:00:00 /usr/lib/frr/pbrd --daemon -A 127.0.0.1\t\r\n5 S root 13240 1 0 75 -5 - 11041 - 02:04 ? 00:00:01 /usr/lib/frr/watchfrr -d -r /usr/sbin/servicebBfrrbBrestartbB%s -s /usr/sbin/servicebBfrrbBstartbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB zebra bgpd ripd ripngd ospfd ospf6d isisd pimd ldpd nhrpd eigrpd pbrd\t\r\n0 S root 13356 9819 0 80 0 - 3556 - 02:34 pts/0 00:00:00 grep --color=auto frr\t\r\nroot@dev:/var/run/frr# cat ospfd.pid\t\r\n13172\t\r\nroot@dev:/var/run/frr# cat ospf6d.pid\t\r\n13180\t\r\nroot@dev:/var/run/frr#\t\r\nroot@dev:/usr/lib/frr# ./ospfd\t\r\n2018/08/24 00:26:49 unknown: Process 22652 has a write lock on file /var/run/frr/ospfd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:26:49 unknown: There is already a OSPFD Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./ospf6d \t\r\n2018/08/24 00:27:11 unknown: Process 22660 has a write lock on file /var/run/frr/ospf6d.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:27:11 unknown: There is already a OSPF6D Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./zebra \t\r\n2018/08/24 00:27:18 unknown: Process 22618 has a write lock on file /var/run/frr/zebra.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:27:18 unknown: There is already a ZEBRA Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./ripd\t\r\n2018/08/24 00:27:30 unknown: Process 22636 has a write lock on file /var/run/frr/ripd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:27:30 unknown: There is already a RIPD Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./ripngd \t\r\n2018/08/24 00:27:38 unknown: Process 22644 has a write lock on file /var/run/frr/ripngd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:27:38 unknown: There is already a RIPNGD Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./nhrpd \t\r\n2018/08/24 00:27:46 unknown: Process 22695 has a write lock on file /var/run/frr/nhrpd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:27:46 unknown: There is already a NHRPD Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./ldpd \t\r\n2018/08/24 00:27:52 unknown: Process 22687 has a write lock on file /var/run/frr/ldpd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:27:52 unknown: There is already a LDPD Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./isisd \t\r\n2018/08/24 00:28:01 unknown: Process 22668 has a write lock on file /var/run/frr/isisd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:28:01 unknown: There is already a ISISD Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./eigrpd \t\r\n2018/08/24 00:28:10 unknown: Process 22704 has a write lock on file /var/run/frr/eigrpd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:28:10 unknown: There is already a EGRPD Process running, hence not allowing a second instance\t\r\nroot@dev:/usr/lib/frr# ./bgpd \t\r\n2018/08/24 00:28:20 unknown: Process 22625 has a write lock on file /var/run/frr/bgpd.pid already! Error :( No such file or directory) \t\r\n\t\r\n2018/08/24 00:28:20 unknown: There is already a BGPD Process running, hence not allowing a second instance)\t\r\n"},"comment":{"url":"https://api.github.com/repos/FRRouting/frr/issues/comments/415833497","html_url":"https://github.com/FRRouting/frr/pull/2902#issuecomment-415833497","issue_url":"https://api.github.com/repos/FRRouting/frr/issues/2902","id":415833497,"node_id":"MDEyOklzc3VlQ29tbWVudDQxNTgzMzQ5Nw==","user":{"login":"donaldsharp","id":10601296,"node_id":"MDQ6VXNlcjEwNjAxMjk2","avatar_url":"https://avatars3.githubusercontent.com/u/10601296?v=4","gravatar_id":"","url":"https://api.github.com/users/donaldsharp","html_url":"https://github.com/donaldsharp","followers_url":"https://api.github.com/users/donaldsharp/followers","following_url":"https://api.github.com/users/donaldsharp/following{/other_user}","gists_url":"https://api.github.com/users/donaldsharp/gists{/gist_id}","starred_url":"https://api.github.com/users/donaldsharp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donaldsharp/subscriptions","organizations_url":"https://api.github.com/users/donaldsharp/orgs","repos_url":"https://api.github.com/users/donaldsharp/repos","events_url":"https://api.github.com/users/donaldsharp/events{/privacy}","received_events_url":"https://api.github.com/users/donaldsharp/received_events","type":"User","site_admin":false},"created_at":"2018-08-24T17:51:00Z","updated_at":"2018-08-24T17:51:00Z","author_association":"MEMBER","body":"@eqvinox yes I was just proposing changing the error message to something a bit more meaningfull when the pid file could not be grabbed."}}
{"actor":{"display_login":"donaldsharp"}}