This project is a little demo that builds a game server with rust, using axum as web framework.
- Redis 7.0.4 >>Install>>
- MongoDB Community 6.0 >>Install>>
See more in Cargo.toml
Start database service. If you have started before, just ignore.
# on macOS
brew services start [email protected]
brew services start redis
MongoDB will listen on 127.0.0.1:27017
by default.
Redis will listen on 127.0.0.1:6379
by default.
If you change the ports that these services listen on, remember to change the configuration in
constant.rs.
If you want to close service, run:
# on macOS
brew services stop [email protected]
brew services stop redis
brew services info ${SERVICE_NAME}
: check the status of the given service.redis-cli
: Open a redis session.mongosh
: Open a mongodb session.
Set the authorization information MONGO_CREDENTIAL_${SUFFIX}
in /constant/secret.rs
.
Go to mongodb with mongosh
and create an administrator in admin database.
use admin
db.createUser({
user: '<USER-NAME>',
pwd: '<PASSWORD>',
roles: [{role:'userAdminAnyDatabase', db: 'admin'}]
})
To enable authorization for mongodb, set /etc/mongod.conf
. If there's no such file, create one.
security:
authorization: "enabled"
Set the connect uri in /job/create_word_list.js
, do load(${Path_to_create_word_list.js})
in
mongosh, the word list should be inserted into db automatically.
cargo run
cargo run --release