Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-gps
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-apps-gps
Commits
65d58636
Commit
65d58636
authored
Jul 08, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified "cmd=start" behavior
parent
2be574ef
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
+29
-10
logger_launcher.php
src/logger_launcher.php
+29
-10
No files found.
src/logger_launcher.php
View file @
65d58636
...
@@ -85,7 +85,9 @@ if (!isset($logger_config[LOGGER_FLEN])) $logger_config[LOGGER_FLEN] = DEFAULT_F
...
@@ -85,7 +85,9 @@ if (!isset($logger_config[LOGGER_FLEN])) $logger_config[LOGGER_FLEN] = DEFAULT_F
if
(
isset
(
$_GET
[
LOGGER_MNT
]))
$logger_config
[
LOGGER_MNT
]
=
$_GET
[
LOGGER_MNT
];
if
(
isset
(
$_GET
[
LOGGER_MNT
]))
$logger_config
[
LOGGER_MNT
]
=
$_GET
[
LOGGER_MNT
];
if
(
isset
(
$_GET
[
LOGGER_DIR
]))
$logger_config
[
LOGGER_DIR
]
=
$_GET
[
LOGGER_DIR
];
if
(
isset
(
$_GET
[
LOGGER_DIR
]))
$logger_config
[
LOGGER_DIR
]
=
$_GET
[
LOGGER_DIR
];
if
(
isset
(
$_GET
[
LOGGER_FILE
]))
$logger_config
[
LOGGER_FILE
]
=
$_GET
[
LOGGER_FILE
];
if
(
isset
(
$_GET
[
LOGGER_FILE
]))
$logger_config
[
LOGGER_FILE
]
=
$_GET
[
LOGGER_FILE
];
if
(
isset
(
$_GET
[
LOGGER_FLEN
]))
$logger_config
[
LOGGER_FLEN
]
=
$_GET
[
LOGGER_FLEN
];
if
(
isset
(
$_GET
[
LOGGER_FLEN
]))
$logger_config
[
LOGGER_FLEN
]
=
$_GET
[
LOGGER_FLEN
];
// will set as string
$logger_config
[
LOGGER_FLEN
]
=
numval
(
$logger_config
[
LOGGER_FLEN
]);
// regardless of origin
//get parameters
//get parameters
if
(
isset
(
$_GET
[
'cmd'
]))
$cmd
=
$_GET
[
'cmd'
];
if
(
isset
(
$_GET
[
'cmd'
]))
$cmd
=
$_GET
[
'cmd'
];
...
@@ -127,12 +129,6 @@ switch ($cmd) {
...
@@ -127,12 +129,6 @@ switch ($cmd) {
$proc
=
getPIDByName
(
'log_imu'
);
$proc
=
getPIDByName
(
'log_imu'
);
$was_running
=
count
(
$proc
)
>
0
;
$was_running
=
count
(
$proc
)
>
0
;
$xml
->
addChild
(
'prev_state'
,
$was_running
?
'RUNNING'
:
'STOPPED'
);
$xml
->
addChild
(
'prev_state'
,
$was_running
?
'RUNNING'
:
'STOPPED'
);
if
(
$was_running
)
{
$xml
->
addChild
(
'error'
,
'was running'
);
add_state_to_xml
(
$xml
);
send_response
(
$xml
);
break
;
}
$dir_path
=
$logger_config
[
LOGGER_MNT
];
$dir_path
=
$logger_config
[
LOGGER_MNT
];
if
(
$logger_config
[
LOGGER_DIR
])
{
if
(
$logger_config
[
LOGGER_DIR
])
{
$dir_path
.=
'/'
.
$logger_config
[
LOGGER_DIR
];
$dir_path
.=
'/'
.
$logger_config
[
LOGGER_DIR
];
...
@@ -140,6 +136,22 @@ switch ($cmd) {
...
@@ -140,6 +136,22 @@ switch ($cmd) {
$pref_path
=
$dir_path
.
'/'
.
$logger_config
[
LOGGER_FILE
];
$pref_path
=
$dir_path
.
'/'
.
$logger_config
[
LOGGER_FILE
];
$xml
->
addChild
(
'dir_path'
,
$dir_path
);
$xml
->
addChild
(
'dir_path'
,
$dir_path
);
$xml
->
addChild
(
'pref_path'
,
$pref_path
);
$xml
->
addChild
(
'pref_path'
,
$pref_path
);
if
(
$was_running
)
{
// 1. See if the path and num_records are the same. If yes, than continue
$same
=
(
$proc
[
0
][
'argv'
]
>
1
)
&&
(
$pref_path
==
$proc
[
0
][
'argv'
][
1
]);
$same
&=
(
$proc
[
0
][
'argv'
]
>
3
)
&&
(
intval
(
$logger_config
[
LOGGER_FLEN
])
==
intval
(
$proc
[
0
][
'argv'
][
3
]));
if
(
!
$same
){
$xml
->
addChild
(
'info'
,
'Have to restart as parameters differ.'
);
// stop previous instance
exec
(
"killall -1 "
.
BIN_NAME
);
exec
(
"sync"
);
// continue as when just starting
}
else
{
$xml
->
addChild
(
'info'
,
'Reusing running instance.'
);
add_state_to_xml
(
$xml
);
break
;
}
}
$indx
=
get_next_index
(
$dir_path
,
$logger_config
[
LOGGER_FILE
]);
$indx
=
get_next_index
(
$dir_path
,
$logger_config
[
LOGGER_FILE
]);
if
(
$indx
==
-
1
){
// create directory recursive if it does not exist
if
(
$indx
==
-
1
){
// create directory recursive if it does not exist
$xml
->
addChild
(
'mkdir'
,
$dir_path
);
$xml
->
addChild
(
'mkdir'
,
$dir_path
);
...
@@ -151,7 +163,7 @@ switch ($cmd) {
...
@@ -151,7 +163,7 @@ switch ($cmd) {
$indx
=
get_next_index
(
$dir_path
,
$logger_config
[
LOGGER_FILE
]);
$indx
=
get_next_index
(
$dir_path
,
$logger_config
[
LOGGER_FILE
]);
}
}
if
(
$indx
==
-
1
)
{
if
(
$indx
==
-
1
)
{
$xml
->
addChild
(
'error'
,
'write dir does not exist'
);
$xml
->
addChild
(
'error'
,
'write dir does not exist'
);
// should not get here as it was just mkder-ed
break
;
break
;
}
}
if
(
$indx
==
-
2
)
{
if
(
$indx
==
-
2
)
{
...
@@ -162,8 +174,12 @@ switch ($cmd) {
...
@@ -162,8 +174,12 @@ switch ($cmd) {
$flen
=
$logger_config
[
LOGGER_FLEN
];
$flen
=
$logger_config
[
LOGGER_FLEN
];
exec
(
"
$exe
$pref_path
$indx
$flen
>/dev/null 2>&1 &"
);
exec
(
"
$exe
$pref_path
$indx
$flen
>/dev/null 2>&1 &"
);
add_state_to_xml
(
$xml
);
add_state_to_xml
(
$xml
);
// save config
$config_xml
=
loggerConfigToXML
(
$logger_config
);
$conf_file
=
fopen
(
LOGGER_CONF
,
"w"
);
fwrite
(
$conf_file
,
$config_xml
->
asXML
());
fclose
(
$conf_file
);
break
;
break
;
case
'state'
:
case
'state'
:
add_state_to_xml
(
$xml
);
add_state_to_xml
(
$xml
);
break
;
break
;
...
@@ -292,7 +308,7 @@ function loggerConfigFromXML($confXML) {
...
@@ -292,7 +308,7 @@ function loggerConfigFromXML($confXML) {
break
;
break
;
default
:
default
:
// $conf[$key]=(int) $item;
// $conf[$key]=(int) $item;
$conf
[
$key
]
=
((
string
)
$item
)
+
0
;
$conf
[
$key
]
=
numval
(
$item
);
// numeric int/float result
}
}
}
}
return
$conf
;
return
$conf
;
...
@@ -322,6 +338,9 @@ function loggerConfigToXML($conf) {
...
@@ -322,6 +338,9 @@ function loggerConfigToXML($conf) {
return
$logger_xml
;
return
$logger_xml
;
}
}
function
numval
(
$str
){
return
((
string
)
$str
)
+
0
;
// numeric int/float result
}
...
...
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