Skip to content
This repository has been archived by the owner on Sep 3, 2024. It is now read-only.

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
joenghoyin committed Aug 30, 2023
1 parent 817cd3a commit 5f280e7
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
2 changes: 1 addition & 1 deletion source/fleetprovisioning/FleetProvisioning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ bool FleetProvisioning::ProvisionDevice(shared_ptr<SharedCrtResourceManager> fpC
LOG_INFO(TAG, "Fleet Provisioning Feature has been started.");

bool didSetup = FileUtils::CreateDirectoryWithPermissions(keyDir.c_str(), S_IRWXU) &&
FileUtils::CreateDirectoryWithPermissions(Config::DEFAULT_CONFIG_DIR, S_IRWXU);
FileUtils::CreateDirectoryWithPermissions(Config::DEFAULT_CONFIG_DIR, S_IRWXU | S_IRGRP | S_IROTH | S_IXOTH);
if (!didSetup)
{
LOGM_ERROR(
Expand Down
14 changes: 14 additions & 0 deletions source/logging/FileLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,20 @@ void FileLogger::run()

while (!needsShutdown)
{
// update watchdog file
struct timespec timeSpec = {0, 0L}; /* Time structure */
time_t retTime = 0; /* Time value to return */

if (clock_gettime(CLOCK_MONOTONIC, &(timeSpec)) == 0)
{
retTime = timeSpec.tv_sec;

ofstream ofs;
ofs.open("/var/run/watchdog.aws-iot-device-client", ofstream::out);
ofs << retTime << std::endl;
ofs.close();
}

unique_ptr<LogMessage> message = logQueue->getNextLog();

if (NULL != message)
Expand Down
2 changes: 1 addition & 1 deletion source/logging/FileLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace Aws
* \brief The default value in milliseconds for which Device client will wait after getting a
* log message from logQueue
*/
static constexpr int DEFAULT_WAIT_TIME_MILLISECONDS = 1;
static constexpr int DEFAULT_WAIT_TIME_MILLISECONDS = 100;

/**
* \brief Flag used to notify underlying threads that they should discontinue any processing
Expand Down
14 changes: 14 additions & 0 deletions source/logging/StdOutLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ void StdOutLogger::run()
{
while (!needsShutdown)
{
// update watchdog file
struct timespec timeSpec = {0, 0L}; /* Time structure */
time_t retTime = 0; /* Time value to return */

if (clock_gettime(CLOCK_MONOTONIC, &(timeSpec)) == 0)
{
retTime = timeSpec.tv_sec;

ofstream ofs;
ofs.open("/var/run/watchdog.aws-iot-device-client", ofstream::out);
ofs << retTime << std::endl;
ofs.close();
}

unique_ptr<LogMessage> message = logQueue->getNextLog();

if (NULL != message)
Expand Down
9 changes: 7 additions & 2 deletions source/tunneling/SecureTunnelingFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,15 @@ namespace Aws
}
if (nServices > 1)
{
LOG_ERROR(
LOGM_INFO(
TAG,
"Received a multi-port tunnel request, but multi-port tunneling is not currently supported "
"by Device Client.");
"by Device Client. region = %s, token = %s", response->Region->c_str(), response->ClientAccessToken->c_str());
string region = response->Region->c_str();
string ClientAccessToken = response->ClientAccessToken->c_str();
string command = "localproxy -d SSH=10.3.2.1:22,GW=10.3.2.1:8080,TIVA=169.254.0.5:502 -r " + region + " -t " + ClientAccessToken + " 2>&1 | tee /var/log/localproxy.log";
int ret = system(command.c_str());
LOGM_INFO(TAG, "Running localproxy instead return code = %d", ret);
return;
}

Expand Down

0 comments on commit 5f280e7

Please sign in to comment.