Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
5d60cd1f
Commit
5d60cd1f
authored
Nov 09, 2016
by
Franco Fichtner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gateways: always restart apinger, HUP doesn't work
parent
a000c8e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
29 deletions
+7
-29
gwlb.inc
src/etc/inc/gwlb.inc
+6
-28
services.inc
src/etc/inc/services.inc
+1
-1
No files found.
src/etc/inc/gwlb.inc
View file @
5d60cd1f
...
...
@@ -42,20 +42,13 @@ function return_apinger_defaults()
);
}
function
setup_gateways_monitor_full
()
{
killbypid
(
'/var/run/apinger.pid'
);
setup_gateways_monitor
();
}
/*
* Creates monitoring configuration file and
* adds appropriate static routes.
*/
function
setup_gateways_monitor
()
{
global
$config
;
killbypid
(
'/var/run/apinger.pid'
,
'TERM'
,
true
);
@
unlink
(
'/var/run/apinger.status'
);
@
mkdir
(
'/var/db/rrd'
,
0775
);
@
chown
(
'/var/db/rrd'
,
'nobody'
);
...
...
@@ -380,27 +373,11 @@ EOD;
$gateways_arr
=
return_gateways_array
();
if
(
!
is_array
(
$gateways_arr
))
{
log_error
(
"No gateways to monitor. Apinger will not be run."
);
killbypid
(
'/var/run/apinger.pid'
);
@
unlink
(
'/var/run/apinger.status'
);
return
;
}
@
file_put_contents
(
'/var/etc/apinger.conf'
,
$apingerconfig
);
unset
(
$apingerconfig
);
/* Restart apinger process */
if
(
isvalidpid
(
'/var/run/apinger.pid'
))
{
killbypid
(
'/var/run/apinger.pid'
,
'HUP'
);
}
else
{
/* start a new apinger process */
@
unlink
(
'/var/run/apinger.status'
);
sleep
(
1
);
mwexec_bg
(
'/usr/local/sbin/apinger -c /var/etc/apinger.conf'
);
sleep
(
1
);
killbypid
(
'/var/run/apinger.pid'
,
'USR1'
);
}
return
0
;
file_put_contents
(
'/var/etc/apinger.conf'
,
$apingerconfig
);
mwexec_bg
(
'/usr/local/sbin/apinger -c /var/etc/apinger.conf'
);
}
/* return the status of the apinger targets as a array */
...
...
@@ -412,6 +389,7 @@ function return_gateways_status($byname = false)
/* Always get the latest status from apinger */
killbypid
(
'/var/run/apinger.pid'
,
'USR1'
);
/* we may read the wrong file here as it's async: */
if
(
file_exists
(
'/var/run/apinger.status'
))
{
$apingerstatus
=
file
(
'/var/run/apinger.status'
);
}
...
...
src/etc/inc/services.inc
View file @
5d60cd1f
...
...
@@ -2471,7 +2471,7 @@ function services_get()
$pconfig
=
array
();
$pconfig
[
'name'
]
=
"apinger"
;
$pconfig
[
'description'
]
=
gettext
(
"Gateway Monitoring Daemon"
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'setup_gateways_monitor
_full
'
);
$pconfig
[
'php'
][
'restart'
]
=
array
(
'setup_gateways_monitor'
);
$pconfig
[
'php'
][
'start'
]
=
array
(
'setup_gateways_monitor'
);
$pconfig
[
'pidfile'
]
=
'/var/run/apinger.pid'
;
$services
[]
=
$pconfig
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment