Jump to content

Running from source: Difference between revisions

No edit summary
No edit summary
Line 26: Line 26:


=== Through Git ===
=== Through Git ===
First, you'll have to open command prompt and navigate to a directory to place your source code. You do not need to create a directory.
First, you'll have to open command prompt and navigate to a directory to place your source code. You do not need to create a directory, but it's recommended to do so. If you prefer, you may type <code>mkdir nwot</code> and then run <code>cd nwot</code> to enter it.


Next, you will have to run the following command: <code>git clone <nowiki>https://github.com/system2k/NodeWorldOfText.git</nowiki> nodeworld</code>
Next, you will have to run the following command: <code>git clone <nowiki>https://github.com/system2k/NodeWorldOfText.git</nowiki> nodeworld</code>
Line 60: Line 60:


== Getting the Server Ready ==
== Getting the Server Ready ==
By this point, you should already ensure that you're inside the source code directory.
By this point, you should already ensure that you're inside the source code directory. It should be the directory containing runserver.js and all the backend files.
[[File:Owot-source-folder.png|none|thumb|506x506px|Screenshot of the source code directory]]


=== Installing packages via NPM ===
The backend of OWOT uses [[wikipedia:Npm|NPM]] (Node Package Manager) to manage its packages.


Stay tuned for more.
You must ensure the packages are installed by running <code>npm install</code>
 
=== Running the server for the first time ===
Once the packages are installed, you can start up the server by running <code>node main.js</code>
 
Your terminal should now look like this:
C:\Users\Username\nwot\nodeworld>node main.js
Starting process...
Starting up...
Created the settings file at [../nwotdata/settings.json]. You must configure the settings file and then start the server back up again.
Full path of settings:C:\Users\Username\nwot\nwotdata\settings.json
Process exited. [0; 0x00000000]
C:\Users\Username\nwot\nodeworld>
The data directory has been generated (named nwotdata) in the parent directory. Navigate to the parent directory and enter the nwotdata directory. You will find a file named settings.json which contains various settings including the port number.
[[File:Owot-settings.png|none|thumb|548x548px|The settings file in the nwotdata directory]]
You may change the port number to any value you want. In most cases, it's fine to leave it as it is but you may change it to, for example, 11001.
 
Once you've changed the settings you want, you may close the text editor and go back to your terminal to run the server again.
 
You'll be prompted to create a superuser account. A superuser account is an administrator account that has the highest privileges and can be used to claim the main world (/).
C:\Users\Username\nwot\nodeworld>node main.js
Starting process...
Starting up...
Loaded libs
Loading page files
Starting server...
Loading static files...
Loading HTML templates...
Compiling HTML templates...
Handling previous error logs (if any)
Initializing server...
You've just installed the server,
which means you don't have any superusers defined.
Would you like to create one now? (yes/no):
If you'd prefer not to create one, enter no. Else enter yes. You'll then be prompted to type in the credentials of your new superuser account.
 
It's highly recommended to create one as you won't be able to claim the main world without one.
Would you like to create one now? (yes/no): yes
Username: admin
Password: **************
Password (again): **************
Superuser created successfully.
OWOT Server is running
Address: ::
Port: 8080
Once you're past that stage, the server should now be running locally on your machine.
 
You will be able to access your local instance of OWOT here: http://localhost:8080
[[File:Owot-instance.png|none|thumb|497x497px|A local instance of the OWOT server]]
Should you need to close down your server, go back to your terminal and either press Ctrl+C or enter <code>stop</code>
 
Any time you need to start your server back up, just go back to your nodeworld directory enter <code>node main.js</code> in the terminal again.
 
== Managing your local instance ==
Once your local instance is up and running, it's time to log in to your superuser account and claim the main world.
 
=== Logging in to your superuser account ===
To log in to your account, hover over the menu and press More...
 
Next, press Login and login with your superuser credentials.
 
You'll then be presented with your profile where you can claim and view your worlds (http://localhost:8080/accounts/profile/).
 
Since you're logged in as a superuser account, you may press the Claim button to claim the main world.
[[File:Owot-claim-mainpage.png|none|thumb|583x583px|Claiming the main page as a superuser]]
Once the main page has been claimed, you can go back to the main page and protect areas.
[[File:Owot-frontpage-admin.png|none|thumb|585x585px|Managing the main page as an admin]]
 
=== Using the administrator panel ===
The [[Admin Panel|admin panel]] is an interface used to manage certain parts of the site.
 
It can be used to quickly access a world's config page, download a world, manage user chat tags, set the announcement, and more.
 
To access it, go to your profile and click on Admin Panel (http://localhost:8080/administrator/).
 
We'll be setting an announcement to test how it works. Scroll down to the Set Announcement section and enter a message. Press Set.
[[File:Owot-admin-announcement.png|none|thumb|555x555px|Setting an announcement on the admin panel]]
You may go back to the main page to see the announcement in action.
 
=== Configuring and using the traffic monitor ===
The traffic monitor displays a comprehensive log of the network and server activities. This is useful for troubleshooting server issues and analyzing attacks on your server.
 
To set up the traffic monitor, close the server which can be done through the admin panel (scroll down to Manage Server and click Close), or by going to the running terminal and pressing Ctrl+C or entering <code>stop</code>
 
Navigate to your nwotdata directory and open settings.json in a text editor.
 
Scroll down to the monitor block and change '''enabled''' from false to true.
 
Set the '''port''' to a number different from your server's port (8081 for example) and set the '''user/pass''' under credentials to something super secure.
 
Set the redirect to the following value: <code><nowiki>http://localhost:8081</nowiki></code> - you may have to change 8081 into the port you used if you're using a different port.
[[File:Owot-monitor-settings.png|none|thumb|547x547px|Configuring the monitor server]]
Save the file and start the server back up.
 
Go back to your profile and click Monitor (http://localhost:8080/administrator/monitor/). It should redirect you to the traffic monitor.
 
The monitor will display what's going on within the server, including new client connections, writes and I/O activity, the backpressure, database status, and the first four characters of messages sent through the /tell chat command.
[[File:Owot-traffic-mon.png|none|thumb|731x731px|Traffic monitor displaying server and network activity.]]
You'll be able to manage the log types that are displayed using the Log Types panel.