Installation
Reference
- Commands Reference - every reldens, reldens-generate and reldens-import command.
- Environment Variables - every RELDENS_* variable supported by .env.
- Installer Guide - what the in-app installer UI does step by step.
- Administration Panel - the first admin login and how to secure it.
This is an example "local" installation process, which can be done in two ways:
- Through NPM / command line:
1 - Create an empty folder for your project, like:
$ mkdir my-game
$ cd my-game
Then you can install the package with:
$ npm install reldens
2 - Or just run the createApp command to create your game-app
(NOTE: this will install the package for you):
$ npm exec reldens createApp my-game
3 - Run Node (a project created with createApp has no start script, so it is always started with node . from the project root):
$ node .
4 - Browse the default URL http://localhost:8080/ to get the installation UI:
Here, you can easily configure the server services requirements. The most important fields are:
- Storage Driver: Knex is selected by default and is always available. Kysely, Drizzle, ObjectionJS, MikroORM and Prisma are also listed, with the " (will be installed)" suffix when their packages are not in your project yet.
- Client: mysql2 is the default for the Knex based drivers. Only the MySQL clients (mysql, mysql2) run the automated SQL scripts, any other client needs the database schema created manually.
- Allow installer to run npm install for missing packages: checked by default, the installer installs the selected driver and mailer packages for you. If you uncheck it, install those packages yourself before submitting the form.
- Admin Panel Secret Key and Signed Tokens Secret Key: both are required and not prefilled, the form is sent back before any database work if one of them is empty. The admin secret signs the administration panel session (it is not your login password), the signed tokens secret signs the reset password links and the multi-server disconnection requests.
- Mailer: None is preselected, pick NodeMailer or SendGrid to enable the emails.
Once you click on the "install" button, the installer will validate the parameters, install the missing packages and import the database SQL scripts to create the tables and insert the required data (like the config or the sample data). Then it generates the entities, creates the project files (.env, .gitignore, install.lock and knexfile.js for the Knex based drivers), starts the game server and redirects you to the game. The installer shows a status message for each step, see the Installer Guide for the full flow and the troubleshooting.
- By GIT fork / clone the skeleton repository (not recommended but available):
https://github.com/damian-pastorini/reldens-skeleton/
1 - Git Clone: make sure you have the proper GitHub keys on your current user or just change the method to HTTPS clone to use your GitHub username/password.
$ git clone git@github.com:damian-pastorini/reldens-skeleton.git ./game
2 - Go into the folder:
$ cd ./game
3 - Run NPM installation:
$ npm install
4 - Login into your MySQL server, create a new database and import the three production files in the following order:
- https://github.com/damian-pastorini/reldens/blob/master/migrations/production/reldens-install-v4.0.0.sql
- https://github.com/damian-pastorini/reldens/blob/master/migrations/production/reldens-basic-config-v4.0.0.sql
- https://github.com/damian-pastorini/reldens/blob/master/migrations/production/reldens-sample-data-v4.0.0.sql
5 - Create or update the .env and knexfile.js with your server credentials. Make sure RELDENS_ADMIN_SECRET and RELDENS_SIGNED_TOKENS_SECRET have values: the administration panel is not activated with an empty admin secret.
IMPORTANT: check the database considerations at the bottom of this page.At this point you could change your database client by setting mysql or mysql2 as your RELDENS_DB_CLIENT environment variable depending on your MySQL server version.
6 - Run Node:
$ node .
7 - Browse the default URL http://localhost:8080/ and the game should run normally.
IMPORTANT: if you remove the install.lock file from the root folder and re-run the process (node .), you will get the installation guide that will help you to install Reldens.
Changing environment variables on runtime:
For example, change the log level:
// linux, gitbash:
$ RELDENS_LOG_LEVEL=9 node .
// windows cmd or powershell:
$ set RELDENS_LOG_LEVEL=9 && node .
Help commands:
Now you can use npx commands.
Reminder: replace [your-theme-name] by your game theme name, in this installation example the theme name is my-game.
These are the basic commands you will need to re-install or rebuild your client:
$ npx reldens help
$ npx reldens installSkeleton [your-theme-name]
$ npx reldens buildCss [your-theme-name]
$ npx reldens buildClient [your-theme-name]
$ npx reldens copyAssetsToDist [your-theme-name]
You are done!
Now, you should be able to browse the default following links:
Game: http://localhost:8080/
Administration Panel: http://localhost:8080/reldens-admin
By default, only the root registered user is an administrator. The basic configuration creates it with the email root@yourgame.com and the password root, so change that password right away or create your own administrator:
$ npx reldens resetPassword --user=root --pass=your-new-password
$ npx reldens createAdmin --user=admin --pass=your-password --email=admin@yourgame.com
The admin role ID (99 in the basic configuration) can be changed by setting the default "admin/roleId" in the "config" table in the database.
UPDATE `config` SET `value` = [new-admin-role-id] WHERE `scope` = 'server' AND `path` = 'admin/roleId';
Client distribution and dist folder:
You can deploy the game in a server and have the client deployed on any CDN.
- The first step will be to have the server installed anywhere. You have many options for this, from any normal cloud service (like an AWS EC2 instance to the Colyseus Cloud). I'm not really going to dig deep in here since how do you architecture your server is not strictly related to this process.
- On your local environment you need to edit the SERVER_URL variable on the game client.
- Build the client and get the contents of the "dist" folder.
- Upload those contents to any CDN.
ENJOY!
IMPORTANT Database considerations
- Make sure to use mysql or mysql2 depending on your MySQL server version (mysql will require the old native authentication, it's recommended to use mysql2).
- Only the MySQL clients run the automated installation scripts. With any other client (PostgreSQL, SQLite, MongoDB, etc.) the installer skips the SQL scripts, so you have to adapt and run the migrations/production/ scripts yourself and then run npx reldens generateEntities --override.
- If you had installed Reldens in the past, and you are planning to use the same database, neither the installer nor the migration scripts will remove any existent tables, and those won't be updated as probably required, so make sure to use an empty database.
- Make sure to change the default admin path from reldens-admin to something else to avoid people to know the path to your administration section.
reldens