Skip to content

Commit

Permalink
some optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Jan 16, 2021
1 parent 7f43a13 commit ab34a18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
6 changes: 6 additions & 0 deletions init/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ _checkDefaultVars() {
test -z ${!key} && eval $key=${def_vals[$key]}
set +a
done
if test $WORKERS -le 0; then
WORKERS=$(($(nproc)+4))
elif test $WORKERS -gt 32; then
WORKERS=32
fi
export MOTOR_MAX_WORKERS=$WORKERS
DOWN_PATH=${DOWN_PATH%/}/
if [[ -n $HEROKU_API_KEY && -n $HEROKU_APP_NAME ]]; then
local herokuErr=$(runPythonCode '
Expand Down
5 changes: 2 additions & 3 deletions init/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,30 @@ initUserge() {
}

startUserge() {
startLogBotPolling
runPythonModule userge "$@"
}

stopUserge() {
sendMessage "Exiting Userge ..."
endLogBotPolling
exit 0
}

handleSigTerm() {
log "Exiting With SIGTERM (143) ..."
stopUserge
endLogBotPolling
exit 143
}

handleSigInt() {
log "Exiting With SIGINT (130) ..."
stopUserge
endLogBotPolling
exit 130
}

runUserge() {
initUserge
startLogBotPolling
startUserge "$@"
stopUserge
}
2 changes: 1 addition & 1 deletion userge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Config:
""" Configs to setup Userge """
API_ID = int(os.environ.get("API_ID"))
API_HASH = os.environ.get("API_HASH")
WORKERS = min(32, int(os.environ.get("WORKERS")) or os.cpu_count() + 4)
WORKERS = int(os.environ.get("WORKERS")) or os.cpu_count() + 4
BOT_TOKEN = os.environ.get("BOT_TOKEN", None)
HU_STRING_SESSION = os.environ.get("HU_STRING_SESSION", None)
OWNER_ID = tuple(filter(lambda x: x, map(int, os.environ.get("OWNER_ID", "0").split())))
Expand Down
5 changes: 4 additions & 1 deletion userge/plugins/misc/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,10 @@ async def gsetup_(message: Message):
""" setup creds """
link = "https://theuserge.github.io/deployment.html#3-g_drive_client_id--g_drive_client_secret"
if Config.G_DRIVE_CLIENT_ID and Config.G_DRIVE_CLIENT_SECRET:
await Worker(message).setup()
if message.chat.id == Config.LOG_CHANNEL_ID:
await Worker(message).setup()
else:
await message.err("try in log channel")
else:
await message.edit(
"`G_DRIVE_CLIENT_ID` and `G_DRIVE_CLIENT_SECRET` not found!\n"
Expand Down

0 comments on commit ab34a18

Please sign in to comment.