TxThinkingInc / brook-user-system

A sample implementation of [Brook User System](https://github.com/txthinking/brook/blob/master/protocol/user.md)
MIT License
7 stars 1 forks source link

how can i create task in command line (in ubuntu) #2

Open nofinori opened 1 month ago

nofinori commented 1 month ago

hi How to create a task in ubuntu command line and how to check the status of tasks? I created a task by using UI, but I can't find it in Joker's list

txthinking commented 1 month ago
  1. When you create a task, it will be inserted into database: https://github.com/TxThinkingInc/brook-user-system/blob/master/main.js#L183

  2. the main thread will run cron: https://github.com/TxThinkingInc/brook-user-system/blob/master/main.js#L11

  3. cron will run task every hour: https://github.com/TxThinkingInc/brook-user-system/blob/master/task.js#L5 I don't if it will block main thread, maybe should write in js worker.

all run in one process, no new process created.

nofinori commented 1 month ago

Thank you, I did it how to disable service for expired or overused traffic max users? i wrote the code to collect the traffic usage from log file and save it in .brook.db but service still available after used more than traffic_max

i set user api when created brook server and my link by this format give me correct response for expired user https://domain.com/path?token=122345 but i don't understand how to use this system for this purpose

txthinking commented 1 month ago

https://github.com/txthinking/brook/blob/master/protocol/user.md#user-api

like here: https://github.com/TxThinkingInc/brook-user-system/blob/master/main.js#L69-L81

I guess you forgot this:

brook --userAPIValidCacheTime value              Once a token is checked and valid, the userAPI will not be requested to validate again for a certain period (s). A reasonable value must be set, otherwise it will affect the performance of each incoming connection (default: 3600)

the default is check every hour

nofinori commented 1 month ago

yes thats right thanks how can I immediately reactivate the user's link after renewing/resetting the user traffic/date? I probably can't set the value of --userAPIInvalidCacheTime very short, like 10 seconds, because the documentation says "A reasonable value must be set". so what is standard way to make available again link as soon?

Another question I have is about this part of the documentation: "--userAPIInvalidCacheTime="": ... Note that this may affect the user experience, when you change the user status from invalid to valid in your user system" What kind of affect does it mean? When a user is invalid, they're definitely disconnected, and when we change them to valid, they connect. What negative effect would this have on the user experience?

txthinking commented 1 month ago

The --userAPIInvalidCacheTime value Once a token is checked and invalid, the userAPI will not be requested to validate again for a certain period (s). A reasonable value must be set, otherwise it will affect the performance of each incoming connection. Note that this may affect the user experience, when you change the user status from invalid to valid in your user system (default: 1800)

This description may need to be modified, probably due to copying :(, I will modify it as follows:

--userAPIInvalidCacheTime value Once a token is checked and invalid, the userAPI will not be requested to validate again for a certain period (s). A reasonable value must be set, otherwise it will affect the performance of each incoming connection. Note that this may affect the user experience, when you change the user status from invalid to valid in your user system (default: 1800)

Just set --userAPIInvalidCacheTime 0, then you can immediately reactivate the user's link after renewing/resetting the user traffic/date.

Let me detail the --userAPIValidCacheTime and --userAPIInvalidCacheTime

brook client -- hi, I want to connect something, this is my connection and my token --> brook server -- hi, please help me to check this token --> brook user system

If --userAPIValidCacheTime is set and not zero:

If --userAPIInvalidCacheTime is set not zero:

nofinori commented 1 month ago

thanks and the last question What I understood is that when we download/copy the serverLog, in that interval between the download/copy and sending the kill -USR1 signal that resets the log, new logs might have been recorded and could be erased when it's reset. Did I understand correctly? Is there a way to save users' usage more accurately so that part of the log isn't lost in this process?

txthinking commented 1 month ago

thanks and the last question What I understood is that when we download/copy the serverLog, in that interval between the download/copy and sending the kill -USR1 signal that resets the log, new logs might have been recorded and could be erased when it's reset. Did I understand correctly?

Correctly. I'm thinking that the data loss won't be too severe, but of course, if you're willing, you can go and read it line by line yourself.

Is there a way to save users' usage more accurately so that part of the log isn't lost in this process?

Sure, just don't send -USR1 to reset the log file, then the log file will always exists and brook will Write ONLY to append. you can write program and deploy to each brook server machine to open it as READ ONLY and watch it and read it line by line and report to your center

nofinori commented 1 month ago

Thank you