Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
familyMart_takeaway
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guanghui.cui
familyMart_takeaway
Commits
1ad7d4a4
Commit
1ad7d4a4
authored
Jul 12, 2022
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix Ubuntn_18.04 OS ps app run error, will while start Daemon and plugin
Version: 1.3.1 RC
parent
443c9bf2
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
55 additions
and
21 deletions
+55
-21
familyMart_takeaway/familyMart_takeaway.vcxproj
+5
-5
fmPluginDaemon/fmPluginDaemon.c
+26
-6
src/main.cpp
+3
-1
takeaway_ut/takeaway_ut.vcxproj
+5
-5
utility/utility.cpp
+14
-4
utility/utility.h
+2
-0
No files found.
familyMart_takeaway/familyMart_takeaway.vcxproj
View file @
1ad7d4a4
...
...
@@ -22,33 +22,33 @@
<ProjectGuid>{B24A017B-387C-49C2-A321-3554AD9A1D48}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>familyMart_takeaway</RootNamespace>
<WindowsTargetPlatformVersion>
8.1
</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
<ProjectName>familyMart_takeaway</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
...
...
fmPluginDaemon/fmPluginDaemon.c
View file @
1ad7d4a4
...
...
@@ -12,7 +12,7 @@
#define BUFSZ 150
// 监控 App 间隔周期 (单位: s)
#define MONITOR_APP_INTERVAL
6
0
#define MONITOR_APP_INTERVAL
12
0
#define MONITOR_APP_NAME "takeaway"
// POS Real Start Command :: nohup /opt/pos/fmtakeout/takeaway > /dev/null &
#define MONITOR_APP_START_COMMAND "nohup /opt/pos/fmtakeout/takeaway > /dev/null & "
...
...
@@ -21,6 +21,8 @@
#define MONITOR_LOG_DIR "/opt/pos/fmtakeout/"
#define MONITOR_LOG_NAME "/opt/pos/fmtakeout/fmPluginDaemon.log"
#define MONITOR_PS_APP_NAME "/opt/pos/fmtakeout/ps"
void
init_daemon
()
{
...
...
@@ -65,7 +67,7 @@ int does_service_work()
int
count
;
char
buf
[
BUFSZ
];
char
command
[
150
];
sprintf
(
command
,
"%s%s%s
"
,
"ps
-ef | grep "
,
MONITOR_APP_NAME
,
" | grep -v grep | wc -l"
);
sprintf
(
command
,
"%s%s%s
%s"
,
MONITOR_PS_APP_NAME
,
"
-ef | grep "
,
MONITOR_APP_NAME
,
" | grep -v grep | wc -l"
);
if
((
fp
=
popen
(
command
,
"r"
))
==
NULL
)
err_quit
(
"popen"
);
...
...
@@ -92,13 +94,31 @@ void main()
fclose
(
fp
);
fp
=
NULL
;
}
// 判断 fmtakeout 目录下是否存在 有可执行权限的 ps 程序
fp
=
fopen
(
MONITOR_LOG_NAME
,
"a"
);
//为记录后续状态,对日志文件进行追加;
if
(
access
(
MONITOR_PS_APP_NAME
,
X_OK
)
==
0
)
{
fprintf
(
fp
,
"FmPluginDaemon:: Current Time Is:%s And The ps App Exist And Has Execute Permission
\n
"
,
asctime
(
localtime
(
&
t
)));
//转换为本地时间输出
fclose
(
fp
);
fp
=
NULL
;
}
else
{
fprintf
(
fp
,
"FmPluginDaemon:: Current Time Is:%s And The ps App Non-Exist Or No Execute Permission
\n
"
,
asctime
(
localtime
(
&
t
)));
//转换为本地时间输出
fclose
(
fp
);
fp
=
NULL
;
exit
(
0
);
}
while
(
1
)
{
sleep
(
MONITOR_APP_INTERVAL
);
//等待一分钟再写入
count
=
does_service_work
();
fp
=
fopen
(
MONITOR_LOG_NAME
,
"a"
);
//为记录后续状态,对日志文件进行追加;
sleep
(
MONITOR_APP_INTERVAL
);
//等待2分钟后再写入
count
=
does_service_work
();
fp
=
fopen
(
MONITOR_LOG_NAME
,
"a"
);
//为记录后续状态,对日志文件进行追加;
if
(
fp
!=
NULL
)
{
time
(
&
t
);
...
...
src/main.cpp
View file @
1ad7d4a4
...
...
@@ -66,10 +66,12 @@ std::string g_plugin_relogin_ods_reason; // 插件重新登录 ODS 的原因;
#ifdef WIN32
bool
bInitDone
=
false
;
//初始化完成
std
::
string
g_pluginAppName
=
"takeaway_d"
;
std
::
string
g_psAppFullName
=
"E:
\\
zouwuyang
\\
FamilyMart
\\
PosPluginClient
\\
familyMart_takeaway
\\
bin
\\
ps"
;
std
::
string
g_appBootStriptFile
=
"E:
\\
zouwuyang
\\
FamilyMart
\\
PosPluginClient
\\
familyMart_takeaway
\\
bin
\\
run_cream.sh"
;
#else
bool
bInitDone
=
false
;
//初始化完成
std
::
string
g_pluginAppName
=
"takeaway"
;
std
::
string
g_psAppFullName
=
"/opt/pos/fmtakeout/ps"
;
std
::
string
g_appBootStriptFile
=
"/opt/pos/bin/run_cream.sh"
;
#endif
...
...
@@ -318,7 +320,7 @@ int main(int argc,char *argv[])
if
(
g_local_pos_init_data
.
length
()
&&
enableLocalPosInitReqTimeOutLimit
>
18
)
{
LOG
(
INFO
)
<<
"PosPlugin Haven't Receive Pos Init Tcp Data, Try Enable Local Pos Init Data File"
;
if
(
PosHandle
::
check_pos_already_exist
()
)
{
LOG
(
INFO
)
<<
"PosPlugin Haven't Receive Pos Init Tcp Data, Check Pos Listen Port Is Ok, Prepare Login ODS...... "
;
LOG
(
INFO
)
<<
"PosPlugin Haven't Receive Pos Init Tcp Data, Check Pos Listen Port Is Ok, Prepare Login ODS...... "
;
g_init_data
=
g_local_pos_init_data
;
bInitDone
=
true
;
}
...
...
takeaway_ut/takeaway_ut.vcxproj
View file @
1ad7d4a4
...
...
@@ -22,32 +22,32 @@
<ProjectGuid>{395675BD-3E73-4656-A9D0-24A94B28C20C}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>takeaway_ut</RootNamespace>
<WindowsTargetPlatformVersion>
8.1
</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion>
10.0
</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v14
0
</PlatformToolset>
<PlatformToolset>v14
2
</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
...
...
utility/utility.cpp
View file @
1ad7d4a4
...
...
@@ -238,9 +238,9 @@ pid_t getPidByName(const char *name)
DIR
*
pdir
=
NULL
;
struct
dirent
*
pde
=
NULL
;
FILE
*
pf
=
NULL
;
char
buff
[
128
]
;
char
buff
[
300
]
=
{
0
}
;
pid_t
pid
;
char
szName
[
128
]
;
char
szName
[
300
]
=
{
0
}
;
pid_t
nowPid
=
getpid
();
LOG
(
INFO
)
<<
"this process pid is:"
<<
nowPid
;
// 遍历/proc目录下所有pid目录
...
...
@@ -346,12 +346,22 @@ void create_process_daemon() {
std
::
string
strDaemonAppPath
(
strBinPath
.
data
());
strDaemonAppPath
.
append
(
"fmPluginDaemon"
);
// 判断 fmtakeout 目录下是否存在 有可执行权限的 fmPluginDaemon 程序
if
(
access
(
strDaemonAppPath
.
c_str
(),
X_OK
)
==
0
)
{
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonAppPath:"
<<
strDaemonAppPath
.
c_str
()
<<
" Exist And Has Execute Permission "
;
}
else
{
LOG
(
INFO
)
<<
"create_process_daemon:: DaemonAppPath:"
<<
strDaemonAppPath
.
c_str
()
<<
" Non-Exist Or No Execute Permission "
;
return
;
}
// 判断 fmtakeout 目录下是否存在 有可执行权限的 ps 程序
if
(
access
(
g_psAppFullName
.
c_str
(),
X_OK
)
==
0
)
{
LOG
(
INFO
)
<<
"create_process_daemon:: psAppPath:"
<<
g_psAppFullName
.
c_str
()
<<
" Exist And Has Execute Permission "
;
}
else
{
LOG
(
INFO
)
<<
"create_process_daemon:: psAppPath:"
<<
g_psAppFullName
.
c_str
()
<<
" Non-Exist Or No Execute Permission "
;
return
;
}
// 3、判断daemon程序是否已经启动,已经启动着无需重复启动;
if
(
does_daemon_work
()
)
...
...
@@ -369,14 +379,14 @@ int does_daemon_work()
{
#ifdef WIN32
LOG
(
INFO
)
<<
"does_daemon_work:: DaemonApp Is Running, No Need Check Status "
;
return
0
;
return
1
;
#else
FILE
*
fp
;
int
count
;
char
buf
[
150
];
char
command
[
150
];
sprintf
(
command
,
"%s%s%s
"
,
"ps
-ef | grep "
,
"fmPluginDaemon"
,
" | grep -v grep | wc -l"
);
sprintf
(
command
,
"%s%s%s
%s"
,
g_psAppFullName
.
c_str
(),
"
-ef | grep "
,
"fmPluginDaemon"
,
" | grep -v grep | wc -l"
);
if
((
fp
=
popen
(
command
,
"r"
))
==
NULL
)
{
LOG
(
INFO
)
<<
"does_daemon_work:: Check DaemonApp Is Running Command Error !!! popen Failed Skip DaemonApp"
;
...
...
utility/utility.h
View file @
1ad7d4a4
...
...
@@ -3,6 +3,8 @@
#include <string>
extern
std
::
string
g_psAppFullName
;
//函数名: GetProcDir()
//功 能: 获取当前程序的路径
std
::
string
GetProcDir
();
...
...
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