Skip to content

Commit

Permalink
Merge pull request #349 from freehackquest/dev
Browse files Browse the repository at this point in the history
version-0.2.37
  • Loading branch information
sea5kg authored Mar 27, 2021
2 parents 1ea3abb + 47956f4 commit 071b171
Show file tree
Hide file tree
Showing 699 changed files with 455 additions and 287 deletions.
8 changes: 4 additions & 4 deletions .code-check.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"paths": [
"fhq-server/src/",
"fhq-server/unit-tests.wsjcpp/src/"
"src/",
"unit-tests.wsjcpp/src/"
],
"exclude": [
"fhq-server/src/core/3rdParty",
"fhq-server/src/3rdParty/quazip-0.7.3",
"src/core/3rdParty",
"src/3rdParty/quazip-0.7.3",
"json.hpp",
".DS_Store"
],
Expand Down
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
ci
code-check
contrib
dckr_fhqserver
docker_dev
fhqjad-store
install
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@ fhq-server-build/
tests/get-pip.py
fhq-server/fhq-server.debian95
.idea

.wsjcpp
fhq-server

contrib/docker_compose_example/logs/*.log
contrib/docker_compose_example/mysql_data
contrib/docker_compose_example/nginx/logs/*.log
9 changes: 6 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@
},
"files.autoSave": "off",
"search.exclude": {
"**/.git": true,
"**/node_modules/**": true,
"**/tmp/**": true
".git": true,
"node_modules": true,
"tmp": true,
"**/packs": true,
"**/log": true,
"log": true
}
}
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@ All notable changes to fhq-server project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [v0.2.37] - ?
## [v0.2.37] - 2021-03-27 (2021 Mar 27)

### Changes

- Redesign docker-compose (moved to contrib/docker_compose_example)
- Moved fhq-server to root of repository
- Moved web-site-admin to web-admin
- Moved user-web-site to web-user

### Security

- Fixed few alerts by lgtm
- Fixed few alerts by deepcode

## [v0.2.36] - 2021-03-15 (2021 Mar 15)

Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ WORKDIR /root/
# Fix for building on debian 9.5 system (mysqlclient library)
# RUN ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/mariadb.pc /usr/lib/x86_64-linux-gnu/pkgconfig/mysqlclient.pc

COPY ./fhq-server /root/fhq-server
COPY . /root/fhq-server
WORKDIR /root/fhq-server
RUN ./clean.sh && ./build_simple.sh

COPY ./user-web-site /root/user-web-site
WORKDIR /root/user-web-site
COPY ./web-user /root/web-user
WORKDIR /root/web-user
RUN npm install && npm run build-prod

FROM freehackquest/fhq-docker-common:latest
Expand All @@ -23,8 +23,8 @@ RUN mkdir -p /usr/share/fhq-server \
&& mkdir -p /usr/share/fhq-server/public/games \
&& mkdir -p /usr/share/fhq-server/web/public/games \
&& mkdir -p /var/log/fhq-server
COPY ./admin-web-site /usr/share/fhq-server/admin-web-site
COPY --from=0 /root/user-web-site/dist /usr/share/fhq-server/user-web-site
COPY ./web-admin /usr/share/fhq-server/web-admin
COPY --from=0 /root/web-user/dist /usr/share/fhq-server/web-user

# 1234 - ws
# 4613 - wss
Expand Down
48 changes: 28 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,17 @@

Backend && Frontend for FreeHackQuest on Qt and WebSockets

**!!! FAST START YOUR GAME** [here (based on docker-compose)](https://github.com/freehackquest/freehackquest-start-game)!!!
## docker-compose example

* [HOW-TO-BUILD-AND-DEVELOP](https://github.com/freehackquest/fhq-server/tree/master/install/HOW-TO-BUILD-AND-DEVELOP.md)
* [INSTALL_FROM_PPA](https://github.com/freehackquest/fhq-server/tree/master/install/INSTALL_FROM_PPA.md)
[docker-compose example](https://github.com/freehackquest/fhq-server/tree/master/contrib/docker_compose_example)


<!-- * [INSTALL_FROM_PPA](https://github.com/freehackquest/fhq-server/tree/master/install/INSTALL_FROM_PPA.md)
* Configure autostart
* [SYSTEMD](install/SYSTEMD.md)
* [INITD](install/INITD.md)
-->

## Distribution

Expand Down Expand Up @@ -46,7 +49,7 @@ $ sudo apt install git-core g++ make cmake qtchooser qt5-default \
build-essential curl
```

Install latest nodejs (for user-web-site)
Install latest nodejs (for web-user)

```
$ curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
Expand Down Expand Up @@ -75,29 +78,29 @@ $ git clone https://github.com/freehackquest/fhq-server ~/fhq-server.git

Build angular:
```
$ cd ~/fhq-server.git/user-web-site
$ cd ~/fhq-server.git/web-user
$ npm install
$ npm run build --prod
```

Build c++ server:

```
$ cd ~/fhq-server.git/fhq-server
$ cd ~/fhq-server.git/
$ ./build_simple.sh
$ ./fhq-server -wd ../ci/travis/data start
$ ./fhq-server -wd ./ci/travis/data start
```

* user-web-site you can see here: `http://localhost:7080/`
* admin-web-site: `http://localhost:7080/admin/`
* web-user you can see here: `http://localhost:7080/`
* web-admin: `http://localhost:7080/admin/`

*Note: default login/password: admin/admin*


Also you can start web angular for develop:
*Will need backend runned (!)*
```
$ cd ~/fhq-server.git/user-web-site
$ cd ~/fhq-server.git/web-user
$ npm run start
```
So you can see web user here: `http://localhost:4200/`
Expand All @@ -107,7 +110,7 @@ So you can see web user here: `http://localhost:4200/`
Build and run unit-tests:

```
$ cd ~/fhq-server.git/fhq-server/unit-tests.wsjcpp
$ cd ~/fhq-server.git/unit-tests.wsjcpp
$ ./build_simple.sh
$ ./unit-tests
```
Expand Down Expand Up @@ -180,13 +183,13 @@ $ sudo apt install valgrind # ubuntu and debian

Terminal1:
```
$ cd ~/fhq-server.git/fhq-server
$ cd ~/fhq-server.git/
$ valgrind --leak-check=full \
--show-leak-kinds=all \
--track-origins=yes \
--verbose \
--log-file=valgrind-out.txt \
./fhq-server -wd ../ci/travis/data
./fhq-server -wd ./ci/travis/data
```

Terminal2:
Expand All @@ -206,12 +209,12 @@ Fast to fix and develop for current server version

```
$ git clone [email protected]:freehackquest/fhq-server.git ~/fhq-server.git
$ cd ~/fhq-server.git/user-web-site
$ cd ~/fhq-server.git/web-user
$ npm install
$ npm run start
```

In a file `~/fhq-server.git/user-web-site/src/app/services/fhq.service.ts`
In a file `~/fhq-server.git/web-user/src/app/services/fhq.service.ts`
And then you can just uncomment line:
```
// baseUrl = 'ws://freehackquest.com/api-ws/';
Expand All @@ -225,6 +228,11 @@ And now your local web site will be connected to offical server.

*Notice: but please never do commit for this line*

## Build docker image

```
$ docker build -t freehackquest/fhq-server:latest .
```

## Ubuntu - install from ppa (outdated)

Expand Down Expand Up @@ -274,8 +282,8 @@ Create directories
$ sudo mkdir /etc/fhq-server/
$ sudo mkdir /var/log/fhq-server/
$ sudo mkdir /usr/share/fhq-server/
$ sudo mkdir /usr/share/fhq-server/admin-web-site
$ sudo mkdir /usr/share/fhq-server/user-web-site
$ sudo mkdir /usr/share/fhq-server/web-admin
$ sudo mkdir /usr/share/fhq-server/web-user
$ sudo mkdir /usr/share/fhq-server/fhqjad-store
```

Expand All @@ -300,8 +308,8 @@ ssl_cert_file = /etc/ssl/certs/test-selfsigned.crt
# Web Configuration
web_port = 7080
web_max_threads = 1
web_admin_folder = /usr/share/fhq-server/admin-web-site
web_user_folder = /usr/share/fhq-server/user-web-site
web_admin_folder = /usr/share/fhq-server/web-admin
web_user_folder = /usr/share/fhq-server/web-user
web_public_folder = /usr/share/fhq-server/public/
web_public_folrer_url = http://localhost:7080/public/
Expand Down Expand Up @@ -469,7 +477,7 @@ jsonResponse["data"] = jsonResult;
pRequest->sendMessageSuccess(cmd(), jsonResponse);
```
admin-web-site paginator:
web-admin paginator:
```
var page_name = 'quests_proposal';
var pg = new SwaPaginator(0, r.data.total, r.data.page_size, r.data.page_index);
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions ci/travis/data/conf.d/fhq-server.conf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ ssl_cert_file = ./test-selfsigned.crt
# Web Configuration
web_port = 7080
web_max_threads = 1
web_admin_folder = ../../../../admin-web-site
web_user_folder = ../../../../user-web-site/dist
web_admin_folder = ../../../../web-admin
web_user_folder = ../../../../web-user/dist

web_public_folder = ../public/
web_public_folrer_url = http://localhost:7080/public/
Expand Down
18 changes: 8 additions & 10 deletions ci/travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,33 @@ check_ret $? "build code-check"
check_ret $? "code-check"
cd ../..

cd fhq-server/unit-tests.wsjcpp
cd unit-tests.wsjcpp
check_ret $? "change directory to unit-tests.wsjcpp"
./build_simple.sh
check_ret $? "build unit-tests"
./unit-tests
check_ret $? "unit-tests"
cd ../..
cd ..

# hardcode for build travis
cd user-web-site
check_ret $? "change directory to user-web-site"
cd web-user
check_ret $? "change directory to web-user"
npm install
check_ret $? "npm install requirements for user-web-site"
check_ret $? "npm install requirements for web-user"
npm run build-prod
check_ret $? "angular build-prod user-web-site"
check_ret $? "angular build-prod web-user"
cd ..

cd fhq-server
check_ret $? "change directory to fhq-server"
python3 -m sea5kg_cpplint
check_ret $? "sea5kg_cpplint"
qmake --version # TODO when will be removed all then qt need remove this line
./build_simple.sh
check_ret $? "build fhq-server"
./fhq-server -wd ../ci/travis/data version
./fhq-server -wd ./ci/travis/data version
check_ret $? "print version of fhq-server"
./fhq-server -wd ../ci/travis/data -cdc
./fhq-server -wd ./ci/travis/data -cdc
check_ret $? "test connection to database"
cd ..

cd fhq-server-tests
check_ret $? "Change directory to tests"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 15 additions & 16 deletions contrib/code_stats/stats.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
#!/bin/bash

function calculateLinesInFiles() {
LINES=0
LINES_CPP=$((find $1 -name "*.cpp" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_CPP))
LINES_H=$((find $1 -name "*.h" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_H))
LINES_HPP=$((find $1 -name "*.hpp" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_HPP))
LINES_C=$((find $1 -name "*.c" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_C))
LINES_CC=$((find $1 -name "*.cc" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_CC))
echo $LINES

LINES=0
LINES_CPP=$((find $1 -name "*.cpp" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_CPP))
LINES_H=$((find $1 -name "*.h" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_H))
LINES_HPP=$((find $1 -name "*.hpp" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_HPP))
LINES_C=$((find $1 -name "*.c" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_C))
LINES_CC=$((find $1 -name "*.cc" -print0 | xargs -0 cat ) | wc -l)
LINES=$(( $LINES + $LINES_CC))
echo $LINES
}

LINES_SRC=$(calculateLinesInFiles "../../fhq-server/src")
LINES_SRC_3RDPARTY=$(calculateLinesInFiles "../../fhq-server/src/3rdParty")
LINES_WSJCPP=$(calculateLinesInFiles "../../fhq-server/src.wsjcpp")
LINES_SRC=$(calculateLinesInFiles "../../src")
LINES_SRC_3RDPARTY=$(calculateLinesInFiles "../../src/3rdParty")
LINES_WSJCPP=$(calculateLinesInFiles "../../src.wsjcpp")

echo "Lines in src: $LINES_SRC"
echo "Lines in src/3rdParty: $LINES_SRC_3RDPARTY"
Expand Down
30 changes: 19 additions & 11 deletions contrib/docker_compose_example/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
# Install from DockerHub
# docker-compose example for fhq-server

You can install fhq-server from
## Reguiremts

```
$ docker pull freehackquest/fhq-server
```
* docker
* docker-compose

## Start

## Using docker-compose
For start just run this:

For example:
```
$ cd ~
$ git clone https://github.com/freehackquest/fhq-server
$ cd ./contrib/docker_compose_example
$ docker-compose up
```

* fhq_conf/[fhq-server.conf](DOCKER_COMPOSE/fhq_conf/fhq-server.conf)
* [docker-compose.yml](DOCKER_COMPOSE/docker-compose.yml)
* fhq_data/games - empty directory for a public
* fhq_logs - empty directory
## Configurations

1. Default port used 801 / 4431 (look in docker-compose)
2. Admin Panel (Login: `admin`; Password: `admin`): http://localhost/admin/?settings=
3. Change settings in
* "Server folders"
* "Mail Settings"
Loading

0 comments on commit 071b171

Please sign in to comment.