Skip to content

Commit

Permalink
update package
Browse files Browse the repository at this point in the history
update logs for email jobs
  • Loading branch information
saroar committed Dec 18, 2023
1 parent 66b3bee commit ba91362
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
28 changes: 14 additions & 14 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/console-kit.git",
"state" : {
"revision" : "7d0898ed481e1855ec549924ab701bdc6f754b18",
"version" : "4.10.2"
"revision" : "a7dd7001196d39b758e4990ec0f26f80162f4c84",
"version" : "4.14.0"
}
},
{
Expand Down Expand Up @@ -131,8 +131,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/leaf-kit.git",
"state" : {
"revision" : "13f2fc4c8479113cd23876d9a434ef4573e368bb",
"version" : "1.10.2"
"revision" : "547a1340b3a063ca738be4351660f59179c8dc34",
"version" : "1.10.3"
}
},
{
Expand Down Expand Up @@ -167,8 +167,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/multipart-kit.git",
"state" : {
"revision" : "1adfd69df2da08f7931d4281b257475e32c96734",
"version" : "4.5.4"
"revision" : "12ee56f25bd3fc4c2d09c2aa16e69de61dc786e8",
"version" : "4.6.0"
}
},
{
Expand Down Expand Up @@ -203,8 +203,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/RediStack.git",
"state" : {
"revision" : "a476f69cbbe31de5ba040309630d365d13c687f8",
"version" : "1.6.1"
"revision" : "622ce440f90d79b58e45f3a3efdd64c51d1dfd17",
"version" : "1.6.2"
}
},
{
Expand Down Expand Up @@ -248,8 +248,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-case-paths",
"state" : {
"revision" : "ed7facdd4a361514b46e3bbc6238cd41c84be4ec",
"version" : "1.1.1"
"revision" : "bba1111185863c9288c5f047770f421c3b7793a4",
"version" : "1.1.3"
}
},
{
Expand All @@ -275,8 +275,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "99d066e29effa8845e4761dd3f2f831edfdf8925",
"version" : "1.0.0"
"revision" : "1827dc94bdab2eb5f2fc804e9b0cb43574282566",
"version" : "1.0.2"
}
},
{
Expand Down Expand Up @@ -383,8 +383,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/vapor.git",
"state" : {
"revision" : "d682e05fdb64c9f7da01af096a73cd11bb7ab755",
"version" : "4.86.2"
"revision" : "67fe736c37b0ad958b9d248f010cff6c1baa5c3a",
"version" : "4.89.3"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Sources/App/Jobs/EmailJobMongoQueue.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct EmailJobMongoQueue: RecurringTask {
do {
_ = try await context.mailgun().send(mailgunMessage).get()
} catch {
print(error)
print("EmailJobMongoQueue ExecutionContext: \(error)")
}
}

Expand All @@ -53,7 +53,7 @@ struct EmailJobMongoQueue: RecurringTask {
// If we failed to run the job for whatever reason (SMTP issue, database issue or otherwise)
func onExecutionFailure(failureContext: QueuedTaskFailure<ExecutionContext>) async throws -> TaskExecutionFailureAction {
// Retry in 1 hour, `nil` for maxAttempts means we never stop retrying
print(failureContext.error)
print("QueuedTaskFailure: \(failureContext.error)")
return .retryAfter(3600, maxAttempts: nil)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ public func authenticationHandler(
)

_ = try await smsAttempt.save(on: request.db).get()
let attemptId = try! smsAttempt.requireID()
//let attemptId = try! smsAttempt.requireID()
guard let attemptId = smsAttempt.id else {
throw Abort(.internalServerError, reason: "Failed to retrieve attempt ID after saving.")
}


let emailPayload = EmailPayload(otpEmail, to: email)
let task = EmailJobMongoQueue(payload: emailPayload, vCodeAttempt: smsAttempt)

do {
try await request.mongoQueue.queueTask(task)
request.logger.info("create queueTask success")
} catch {
request.logger.info("\(error)")
request.logger.error("create queueTask: \(error)")
}

return EmailLoginOutput(
Expand Down
54 changes: 30 additions & 24 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
version: '3.9'

x-shared_environment: &shared_environment
LOG_LEVEL: ${LOG_LEVEL:-debug}
LOG_LEVEL: ${LOG_LEVEL:-info}
JWTS: "${JWTS}"
MONGO_DB_PRODUCTION_URL: '${MONGO_DB_PRODUCTION_URL}'
MONGO_DB_PRODUCTION_URL: "${MONGO_DB_PRODUCTION_URL}"

TWILIO_ACCOUNT_ID: "${TWILIO_ACCOUNT_ID}"
TWILIO_ACCOUNT_SECRET: "${TWILIO_ACCOUNT_SECRET}"
SENDER_NUMBER: "+16097579519"

APNS_KEY_ID: "${APNS_KEY_ID}"
APNS_PRIVATE_KEY: "${APNS_PRIVATE_KEY}"
APNS_TEAM_ID: "${APNS_TEAM_ID}"
Expand All @@ -15,43 +17,47 @@ x-shared_environment: &shared_environment
REDIS_URL_PRODUCTION: '${REDIS_URL_PRODUCTION}'

services:
mongo:
image: mongo:latest
container_name: AddameProduction
environment:
- AUTH=yes
- MONGODB_ADMIN_USER='${MONGODB_ADMIN_USER}'
- MONGODB_ADMIN_PASS='${MONGODB_ADMIN_PASS}'
- MONGO_INITDB_ROOT_USERNAME='${MONGODB_USER_PRODUCTION}'
- MONGO_INITDB_ROOT_PASSWORD='${MONGODB_PASS_PRODUCTION}'
- MONGO_INITDB_DATABASE='${MONGODB_DATABASE_PRODUCTION}'
volumes:
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
- ./mongodb/data:/data/db
networks:
- production_gateway
restart: unless-stopped
ports:
- "27018:27017"
mongo:
image: mongo:latest
container_name: AddameMongoPro
environment:
- AUTH=yes
- MONGODB_ADMIN_USER='${MONGODB_ADMIN_USER}'
- MONGODB_ADMIN_PASS='${MONGODB_ADMIN_PASS}'
- MONGO_INITDB_ROOT_USERNAME='${MONGODB_USER_PRODUCTION}'
- MONGO_INITDB_ROOT_PASSWORD='${MONGODB_PASS_PRODUCTION}'
- MONGO_INITDB_DATABASE='${MONGODB_DATABASE_PRODUCTION}'

volumes:
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro
- ./mongodb/data:/data/db
networks:
- addame_pro_gateway
restart: unless-stopped

addame_server:
image: addamespb/addame_server:latest
container_name: agateway
container_name: addameServer
build:
context: addameServer
environment:
<<: *shared_environment
ports:
- '80:8080'
- '443:8080'
- '8080:8080'
command: ["serve", "--env", "production", "--hostname", "0.0.0.0", "--port", "8080"]
volumes:
- ~/addameServer:/addameServer_data
- ./.env:/app/.env
- ./.env.production:/app/.env.production
depends_on:
- mongo
networks:
- production_gateway
- addame_pro_gateway
restart: unless-stopped
env_file:
- ./.env

redis:
container_name: redisProAddame
Expand All @@ -63,12 +69,12 @@ services:
volumes:
- redis-persistence-production:/bitnami/redis/data
networks:
- production_gateway
- addame_pro_gateway

volumes:
addameServer:
redis-persistence-production:

networks:
production_gateway:
addame_pro_gateway:
name: Default

0 comments on commit ba91362

Please sign in to comment.