nginx setup and make
This commit is contained in:
parent
264d368351
commit
fac62329e8
22
bin/build.sh
22
bin/build.sh
@ -5,9 +5,13 @@ DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|||||||
MNML_PATH=$(realpath "$DIR/../")
|
MNML_PATH=$(realpath "$DIR/../")
|
||||||
|
|
||||||
if [ ! -f $MNML_PATH/etc/mnml.env ]; then
|
if [ ! -f $MNML_PATH/etc/mnml.env ]; then
|
||||||
echo "create an env file in $MNML_PATH/etc/mnml.env"
|
echo "-----------------------------------------------"
|
||||||
echo "see $MNML_PATH/etc/mnml.SAMPLE.env for details"
|
echo "creating an env file in $MNML_PATH/etc/mnml.env"
|
||||||
exit 1;
|
echo "-----------------------------------------------"
|
||||||
|
|
||||||
|
echo "export MNML_USER=\"$(whoami)\"" >> $MNML_PATH/etc/mnml.env
|
||||||
|
echo "export MNML_PG_PASSWORD=\"$(openssl rand -base64 16)\"" >> $MNML_PATH/etc/mnml.env
|
||||||
|
echo "export MNML_PG_HOST=\"localhost\"" >> $MNML_PATH/etc/mnml.env
|
||||||
fi
|
fi
|
||||||
|
|
||||||
source $MNML_PATH/etc/mnml.env
|
source $MNML_PATH/etc/mnml.env
|
||||||
@ -40,18 +44,22 @@ sudo -u postgres psql -c "alter user mnml with encrypted password '$MNML_PG_PASS
|
|||||||
cd $MNML_PATH/ops && npm run migrate
|
cd $MNML_PATH/ops && npm run migrate
|
||||||
|
|
||||||
# RUST SETUP
|
# RUST SETUP
|
||||||
|
echo "DATABASE_URL=postgres://mnml:$MNML_PG_PASSWORD@$MNML_PG_HOST/mnml" > $MNML_PATH/server/.env
|
||||||
# cargo build
|
# cargo build
|
||||||
# cp -r $MNML_PATH/server/target/release /opt/mnml/bin
|
# cp -r $MNML_PATH/server/target/release /opt/mnml/bin
|
||||||
|
|
||||||
# NGINX
|
# NGINX
|
||||||
if [ ! -f $MNML_PATH/etc/nginx/sites-available/mnml.gg.nginx.conf ]; then
|
if [ ! -f $MNML_PATH/etc/nginx/sites-available/mnml.gg.nginx.conf ]; then
|
||||||
echo "create an env file in $MNML_PATH/etc/nginx/sites-available/mnml.gg.nginx.conf"
|
echo "-----------------------------------------------"
|
||||||
echo "see $MNML_PATH/etc/nginx/sites-available/mnml.gg.DEV.nginx.conf for details"
|
echo "using development nginx config"
|
||||||
exit 1;
|
echo "$MNML_PATH/etc/nginx/sites-available/mnml.gg.nginx.conf"
|
||||||
|
echo "-----------------------------------------------"
|
||||||
|
|
||||||
|
cp $MNML_PATH/etc/nginx/sites-available/mnml.gg.DEV.nginx.conf $MNML_PATH/etc/nginx/sites-available/mnml.gg.nginx.conf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sudo cp $MNML_PATH/etc/nginx/sites-available/mnml.gg.nginx.conf /etc/nginx/sites-available
|
sudo cp $MNML_PATH/etc/nginx/sites-available/mnml.gg.nginx.conf /etc/nginx/sites-available
|
||||||
sudo ln -nfs /etc/nginx/sites-available/mnml.gg.nginx.conf /etc/nginx/sites-enabled/mnml.gg.nginx.conf
|
sudo ln -nfs /etc/nginx/sites-available/mnml.gg.nginx.conf /etc/nginx/sites-enabled/mnml.gg.nginx.conf
|
||||||
cd $MNML_PATH/client && npm run build
|
# cd $MNML_PATH/client && npm run build
|
||||||
|
|
||||||
sudo service nginx restart
|
sudo service nginx restart
|
||||||
|
|||||||
@ -4,9 +4,9 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "parcel watch index.html --out-dir /var/lib/mnml/public",
|
"start": "parcel watch index.html --out-dir /var/lib/mnml/public/dist",
|
||||||
"anims": "parcel animations.html --host 0.0.0.0 --port 40080 --no-source-maps",
|
"anims": "parcel animations.html --host 0.0.0.0 --port 40080 --no-source-maps",
|
||||||
"build": "parcel build index.html --out-dir /var/lib/mnml/public",
|
"build": "parcel build index.html --out-dir /var/lib/mnml/public/dist",
|
||||||
"scss": "node-sass --watch assets/scss -o assets/styles",
|
"scss": "node-sass --watch assets/scss -o assets/styles",
|
||||||
"lint": "eslint --fix --ext .jsx src/",
|
"lint": "eslint --fix --ext .jsx src/",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
|||||||
@ -7,7 +7,7 @@ const actions = require('./actions');
|
|||||||
const { TIMES } = require('./constants');
|
const { TIMES } = require('./constants');
|
||||||
const { getCombatSequence } = require('./utils');
|
const { getCombatSequence } = require('./utils');
|
||||||
|
|
||||||
const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://mnml.gg/api/ws' : 'ws://localhost:40000/api/ws';
|
const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://mnml.gg/api/ws' : 'ws://localhost/api/ws';
|
||||||
|
|
||||||
function createSocket(store) {
|
function createSocket(store) {
|
||||||
let ws = null;
|
let ws = null;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
const toast = require('izitoast');
|
const toast = require('izitoast');
|
||||||
const cbor = require('borc');
|
const cbor = require('borc');
|
||||||
|
|
||||||
const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://mnml.gg/api/ws' : 'ws://localhost:40000/api/ws';
|
const SOCKET_URL = process.env.NODE_ENV === 'production' ? 'wss://mnml.gg/api/ws' : 'ws://localhost/api/ws';
|
||||||
|
|
||||||
function errorToast(err) {
|
function errorToast(err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|||||||
@ -352,11 +352,9 @@ const removeTier = skill => {
|
|||||||
return skill;
|
return skill;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const SERVER = process.env.NODE_ENV === 'production' ? '/api/' : 'http://localhost:40000/api';
|
|
||||||
function postData(url = '/', data = {}) {
|
function postData(url = '/', data = {}) {
|
||||||
// Default options are marked with *
|
// Default options are marked with *
|
||||||
return fetch(`${SERVER}${url}`, {
|
return fetch(`/api${url}`, {
|
||||||
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
method: 'POST', // *GET, POST, PUT, DELETE, etc.
|
||||||
// mode: 'no-cors', // no-cors, cors, *same-origin
|
// mode: 'no-cors', // no-cors, cors, *same-origin
|
||||||
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached
|
||||||
@ -379,7 +377,6 @@ module.exports = {
|
|||||||
getCombatSequence,
|
getCombatSequence,
|
||||||
getCombatText,
|
getCombatText,
|
||||||
postData,
|
postData,
|
||||||
SERVER,
|
|
||||||
NULL_UUID,
|
NULL_UUID,
|
||||||
STATS,
|
STATS,
|
||||||
COLOURS,
|
COLOURS,
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
error_log /var/log/nginx/mnml.nginx.log debug;
|
||||||
|
|
||||||
upstream mnml {
|
upstream mnml {
|
||||||
server 127.0.0.1:40000;
|
server 127.0.0.1:40000;
|
||||||
}
|
}
|
||||||
@ -9,10 +11,9 @@ map $http_upgrade $connection_upgrade {
|
|||||||
|
|
||||||
# DEV
|
# DEV
|
||||||
server {
|
server {
|
||||||
root /var/lib/mnml/public/;
|
|
||||||
index index.html;
|
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
root /var/lib/mnml/public/dist;
|
||||||
|
index index.html;
|
||||||
try_files $uri $uri/ =404;
|
try_files $uri $uri/ =404;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
23
ops/migrations/20190709132153_mtx.js
Normal file
23
ops/migrations/20190709132153_mtx.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
exports.up = async knex => {
|
||||||
|
await knex.schema.createTable('mtx', table => {
|
||||||
|
table.uuid('id')
|
||||||
|
.primary();
|
||||||
|
|
||||||
|
table.uuid('account')
|
||||||
|
.notNullable()
|
||||||
|
.index();
|
||||||
|
|
||||||
|
table.foreign('account')
|
||||||
|
.references('id')
|
||||||
|
.inTable('accounts')
|
||||||
|
.onDelete('RESTRICT');
|
||||||
|
|
||||||
|
table.string('variant')
|
||||||
|
.notNullable()
|
||||||
|
.index();
|
||||||
|
|
||||||
|
table.timestamps(true, true);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.down = async () => {};
|
||||||
@ -231,7 +231,8 @@ pub fn account_create(name: &String, password: &String, code: &String, tx: &mut
|
|||||||
None => return Err(err_msg("account not created")),
|
None => return Err(err_msg("account not created")),
|
||||||
};
|
};
|
||||||
|
|
||||||
for _i in 0..3 {
|
// 3 constructs for a team and 1 to swap
|
||||||
|
for _i in 0..4 {
|
||||||
construct_spawn(tx, ConstructSpawnParams { name: generate_name() }, id)?;
|
construct_spawn(tx, ConstructSpawnParams { name: generate_name() }, id)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user