Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Erik Jansen
crown-core-test-new-gitlab-runner
Commits
95326aca
Commit
95326aca
authored
7 years ago
by
Ashot
Browse files
Options
Download
Email Patches
Plain Diff
Added restart functionality
parent
22b46f52
No related merge requests found
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
src/crownd.cpp
+20
-0
src/crownd.cpp
src/init.cpp
+8
-0
src/init.cpp
src/init.h
+2
-0
src/init.h
src/rpcserver.cpp
+12
-0
src/rpcserver.cpp
src/rpcupdate.cpp
+3
-0
src/rpcupdate.cpp
src/updater.cpp
+18
-1
src/updater.cpp
src/updater.h
+1
-0
src/updater.h
with
64 additions
and
1 deletion
+64
-1
src/crownd.cpp
View file @
95326aca
...
...
@@ -35,6 +35,7 @@
*/
static
bool
fDaemon
;
std
::
string
appPath
;
void
DetectShutdownThread
(
boost
::
thread_group
*
threadGroup
)
{
...
...
@@ -186,6 +187,21 @@ bool AppInit(int argc, char* argv[])
delete
detectShutdownThread
;
detectShutdownThread
=
NULL
;
}
if
(
RestartRequested
())
{
// If restart requested cleanup resources and run application again.
// The old one will be exited below.
PrepareShutdown
();
CExplicitNetCleanup
::
callCleanup
();
if
(
appPath
.
empty
())
{
fprintf
(
stderr
,
"Error: Application name couldn't be detected."
);
}
else
{
runCommand
(
appPath
+
" &"
);
}
}
Shutdown
();
return
fRet
;
...
...
@@ -193,6 +209,10 @@ bool AppInit(int argc, char* argv[])
int
main
(
int
argc
,
char
*
argv
[])
{
if
(
argc
>
0
)
{
appPath
=
std
::
string
(
argv
[
0
]);
}
SetupEnvironment
();
// Connect crownd signal handlers
...
...
This diff is collapsed.
Click to expand it.
src/init.cpp
View file @
95326aca
...
...
@@ -122,10 +122,18 @@ void StartShutdown()
{
fRequestShutdown
=
true
;
}
void
StartRestart
()
{
fRestartRequested
=
true
;
}
bool
ShutdownRequested
()
{
return
fRequestShutdown
||
fRestartRequested
;
}
bool
RestartRequested
()
{
return
fRestartRequested
;
}
class
CCoinsViewErrorCatcher
:
public
CCoinsViewBacked
{
...
...
This diff is collapsed.
Click to expand it.
src/init.h
View file @
95326aca
...
...
@@ -18,7 +18,9 @@ class thread_group;
extern
CWallet
*
pwalletMain
;
void
StartShutdown
();
void
StartRestart
();
bool
ShutdownRequested
();
bool
RestartRequested
();
void
Shutdown
();
void
PrepareShutdown
();
bool
AppInit2
(
boost
::
thread_group
&
threadGroup
);
...
...
This diff is collapsed.
Click to expand it.
src/rpcserver.cpp
View file @
95326aca
...
...
@@ -235,6 +235,17 @@ Value stop(const Array& params, bool fHelp)
return
"Crown server stopping"
;
}
Value
restart
(
const
Array
&
params
,
bool
fHelp
)
{
// Accept the deprecated and ignored 'detach' boolean argument
if
(
fHelp
||
params
.
size
()
>
1
)
throw
runtime_error
(
"restart
\n
"
"
\n
Restart Crown server."
);
// Restart will take long enough that the response should get back
StartRestart
();
return
"Crown server restarting"
;
}
/**
...
...
@@ -247,6 +258,7 @@ static const CRPCCommand vRPCCommands[] =
{
"control"
,
"getinfo"
,
&
getinfo
,
true
,
false
,
false
},
/* uses wallet if enabled */
{
"control"
,
"help"
,
&
help
,
true
,
true
,
false
},
{
"control"
,
"stop"
,
&
stop
,
true
,
true
,
false
},
{
"control"
,
"restart"
,
&
restart
,
true
,
true
,
false
},
/* P2P networking */
{
"network"
,
"getnetworkinfo"
,
&
getnetworkinfo
,
true
,
false
,
false
},
...
...
This diff is collapsed.
Click to expand it.
src/rpcupdate.cpp
View file @
95326aca
...
...
@@ -106,6 +106,9 @@ void RPCInstall()
}
else
{
RPCUpdate
::
statusObj
.
push_back
(
Pair
(
"Install"
,
"Done"
));
}
// Restart crownd
StartRestart
();
}
boost
::
filesystem
::
remove_all
(
dir
);
...
...
This diff is collapsed.
Click to expand it.
src/updater.cpp
View file @
95326aca
...
...
@@ -4,6 +4,7 @@
#include "updater.h"
#include "clientversion.h"
#include "util.h"
#include "chainparams.h"
#include <stdio.h>
#include <curl/curl.h>
...
...
@@ -19,7 +20,6 @@ struct myprogress {
Updater
updater
;
Updater
::
Updater
()
:
updaterInfoUrl
(
"https://raw.githubusercontent.com/ashotkhachatryan/crowncoin/systemnode/update1.json"
),
os
(
Updater
::
UNKNOWN
),
status
(
false
),
version
(
-
1
),
...
...
@@ -80,11 +80,28 @@ bool Updater::NeedToBeUpdated()
return
false
;
}
void
Updater
::
SetJsonPath
()
{
if
(
updaterInfoUrl
.
empty
())
{
if
(
Params
().
NetworkID
()
==
CBaseChainParams
::
MAIN
)
{
updaterInfoUrl
=
"https://raw.githubusercontent.com/Crowndev/crowncoin/master/update.json"
;
}
else
{
updaterInfoUrl
=
"https://raw.githubusercontent.com/Crowndev/crowncoin/master/update_testnet.json"
;
}
}
std
::
cout
<<
updaterInfoUrl
<<
std
::
endl
;
}
bool
Updater
::
LoadUpdateInfo
()
{
bool
result
=
false
;
CURL
*
curl
;
std
::
string
updateData
;
SetJsonPath
();
CURLcode
res
=
CURLE_FAILED_INIT
;
curl
=
curl_easy_init
();
if
(
curl
)
...
...
This diff is collapsed.
Click to expand it.
src/updater.h
View file @
95326aca
...
...
@@ -55,6 +55,7 @@ private:
std
::
string
updaterInfoUrl
;
bool
LoadUpdateInfo
();
Value
ParseJson
(
std
::
string
info
);
void
SetJsonPath
();
void
SetOS
();
bool
NeedToBeUpdated
();
int
GetVersionFromJson
();
...
...
This diff is collapsed.
Click to expand it.
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
Menu
Projects
Groups
Snippets
Help