Table of Contents
ducere
is a CLI tool for Basolato framework such as rake
/php artisan
.
Create new project
pwd
> /user/local/src
ducere new my_project
> Created project /user/local/src/my_project
pwd
> /user/local/src
mkdir my_project
cd my_project
ducere new .
> Created project /user/local/src/my_project
Run develop server with hot reload
Usage:
serve [optional-params]
Run dev application with hot reload
Options:
-h, --help print this cligen-erated help
--help-syntax advanced: prepend,plurals,..
--version bool false print version
-p=, --port= int 5000 set port
ducere serve
The default port is 5000. If you want to change it, specify with option -p
ducere serve -p:8000
Compiling for production.
By default, it will be compiled to run 5000 port and multithreaded for the number of cores in your PC.
Usage:
build [optional-params] [args: string...]
Build for production.
Options:
-h, --help print this cligen-erated help
--help-syntax advanced: prepend,plurals,..
--version bool false print version
-p=, --ports= string "5000" set ports
-t=, --threads= string "off" set threads
ducere build
./main
>> Starting 4 threads
>> Listening on port 5000
When you specify multi ports, it will be compiled to run each port and singlethreaded.
Running with Multithreads is buggy. I recommand to compile for singlethreaded and run with nginx road balancer.
ducere build -p:5000,5001,5002
>> generated main5000, main5001, main5002
./main5000
>> Starting 1 thread
>> Listening on port 5000
./main5001
>> Starting 1 thread
>> Listening on port 5001
Here is a sample to run in production environment.
autorestart.sh
ducere build -p:5000,5001,5002,5003
while [ 1 ]; do
./main5000 & \
./main5001 & \
./main5002 & \
./main5003
done
nginx.conf
worker_processes auto;
worker_rlimit_nofile 150000;
events {
worker_connections 65535;
multi_accept on;
use epoll;
}
http {
access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log info;
tcp_nopush on;
upstream basolato {
least_conn;
server 127.0.0.1:5000;
server 127.0.0.1:5001;
server 127.0.0.1:5002;
server 127.0.0.1:5003;
}
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
server {
listen 443;
ssl on;
server_name www.example.com;
ssl_certificate /etc/pki/tls/certs/example_com_combined.crt; # path to certification
ssl_certificate_key /etc/pki/tls/private/example_com.key; # path to private key
location / {
proxy_pass http://basolato;
}
}
}
ducere migrate
This is a alias for nim c -r migrations/migrate
ducere migrate clear
Dropping all tables from the database. Target database is loaded in .env.local
.
ducere migrate fresh
Dropping all tables from the database and then execute the migrate command. Target database is loaded in .env.local
.
Create new file
Create config.nims
for database connection, logging, session-timeout configuation.
ducere make config
Create new controller
ducere make controller user
>> app/http/controllers/user_controller.nim
ducere make controller sample/user
>> app/http/controllers/sample/user_controller.nim
ducere make controller sample/sample2/user
>> app/http/controllers/sample/sample2/user_controller.nim
Create new view template.
layout
is a part of components. page
is a view that called by controller.
ducere make layout buttons/success_button
>> app/http/views/layouts/buttons/success_button_view.nim
ducere make page login
>> app/http/views/pages/login_view.nim
Create new migration file
ducere make migration create_user
>> migrations/migration20200219134020create_user.nim
ducere make model circle
in app/core/models
circle
├── circle_entity.nim
├── circle_repository_interface.nim
└── circle_service.nim
in app/repositories
circle
└── circle_rdb_repository.nim
ducere make model circle/user
in app/core/models
circle
├── circle_entity.nim
├── circle_repository_interface.nim
├── circle_service.nim
└── user
├── user_entity.nim
└── user_service.nim
Create new usecase
ducere make usecase login
>> app/core/usecases/login_usecase.nim
Add new minimum value object boilerplate.
ducere make valueobject {arg1} {arg2}
arg1
is a name of value object which should be Camel Case.
arg2
specifies the name of the aggregate to which the value object will be written. Ex: app/core/models{aggregate}/{aggregate}_value_object
.
ducere make valueobject UserName user
>> add UserName in app/domain/models/user/user_value_objects.nim
Clone this repository if you want to use bash-completion
for ducere
.
git clone https://github.com/itsumura-h/nim-basolato /path/to/nim-basolato
And add this shell script to ~/.bashrc
.
source /path/to/nim-basolato/completions/bash/ducere
Or, copy completion file to directory.
sudo install -o root -g root -m 0644 /path/to/nim-basolato/completions/bash/ducere /usr/share/bash-completion/completions/ducere