2 Star 3 Fork 3

alchemy / ziply

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
README.md 5.64 KB
一键复制 编辑 原始数据 按行查看 历史
ZoomQuiet 提交于 2020-10-19 21:27 . 👌 IMPROVE:

ziply

zip url like bitly/TinyURL/...

doc:中文

ShortEner

myself yet shorten URL service

install

need Elixir >= 1.9

base Installing Elixir - The Elixir programming language install local develop environment.

$ elixir -v

if see like:

Erlang/OTP 22 [erts-10.5.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.9.1 (compiled with Erlang/OTP 22)

confirm u local environment is ok;

now, let's running:

$ git clone https://gitee.com/alchemists/ziply.git

and creat database path:

$ mkdir priv

now local path will like:

path/2/u/path:
    +- priv/
    +- ziply/
        +- short_ener
        +- LICENSE
        +- README.md

$ cd ziply/short_ener

enter application path;

$ mix deps.get && mix deps.compile

download and compile all depend module;

$ mix run --no-halt

run by mix , will see terminal export like:

Compiling 11 files (.ex)
Generated short_ener app

15:10:06.079 [debug] will init. in /opt/scm/srv/sp4ias/main_ziply/short_ener/../../priv/mnesia.dev.nonode@nohost

15:10:06.079 [debug] only master init.
---> Processes holding locks <---
---> Processes waiting for locks <---
---> Participant transactions <---
---> Coordinator transactions <---
---> Uncertain transactions <---
---> Active tables <---
schema         : with 4        records occupying 783      words of mem
links          : with 1        records occupying 405      words of mem
counter        : with 1        records occupying 318      words of mem
id_seq         : with 0        records occupying 5464     bytes on disc
===> System info in version "4.16.1", debug level = none <===
opt_disc. Directory "/opt/scm/srv/sp4ias/main_ziply/short_ener/../../priv/mnesia.dev.nonode@nohost" is used.
use fallback at restart = false
running db nodes   = [nonode@nohost]
stopped db nodes   = []
master node tables = []
remote             = []
ram_copies         = []
disc_copies        = [counter,links,schema]
disc_only_copies   = [id_seq]
[{nonode@nohost,disc_copies}] = [counter,links,schema]
[{nonode@nohost,disc_only_copies}] = [id_seq]
2 transactions committed, 2 aborted, 0 restarted, 0 logged to disc
0 held locks, 0 in queue; 0 local transactions, 0 remote
0 transactions waits for other nodes: []
:ok

15:10:06.257 [info]  running ShortEner...at 9081

15:10:06.284 [info]  Application mnesia exited: :stopped

now ShortEner is wait service for u.

usage

MVP yet, only support 3 tiny base functions

alive echo

$ curl localhost:9081/ping

echo:

pong ;-)
I'm alive.

generate short URL:

$ curl localhost:9081/api -X POST -d 'url=https://qq.com/'

if post new URL:

Ziply: t.101.s/qogl ~> https://qq.com/

else deiscover URL exist:

Ziped: t.101.s/qogl ~> https://qq.com/

re-direct

visit in browser:

-> http://t.101.s/qogl

deploy

recommand base mix release:

in u host:

$ cd path/2/u/ziply/short_ener

enter cloned path,

$ mix release.init

initialize release

* creating rel/vm.args.eex
* creating rel/env.sh.eex
* creating rel/env.bat.eex

$ MIX_ENV=prod mix release --overwrite

compile as product;

...
Release created at _build/prod/rel/short_ener!
    # To start your system
    _build/prod/rel/short_ener/bin/short_ener start
Once the release is running:
    # To connect to it remotely
    _build/prod/rel/short_ener/bin/short_ener remote
    # To stop it gracefully (you may also send SIGINT/SIGTERM)
    _build/prod/rel/short_ener/bin/short_ener stop
To list all commands:
    _build/prod/rel/short_ener/bin/short_ener

succeed, can see like that, try first:

$ _build/prod/rel/short_ener/bin/short_ener

if read like this, confirm Ziply is already running as one Server:

Usage: short_ener COMMAND [ARGS]

The known commands are:

    start          Starts the system
    start_iex      Starts the system with IEx attached
    daemon         Starts the system as a daemon
    daemon_iex     Starts the system as a daemon with IEx attached
    eval "EXPR"    Executes the given expression on a new, non-booted system
    rpc "EXPR"     Executes the given expression remotely on the running system
    remote         Connects to the running system via a remote shell
    restart        Restarts the running system via a remote command
    stop           Stops the running system via a remote command
    pid            Prints the OS PID of the running system via a remote command
    version        Prints the release name and version to be booted

plan and trace

  • Dev:
    • POST API
    • GET API
      • /
      • /ping
      • /ziplty: 302 跳转
      • count visit
    • SSL
  • Ops:
    • public as t.101.so
    • test case
    • deploy in https
    • authentication/admin API
    • Mnesia DBA
      • backup
      • migrate
      • restore
      • distribution
  • Prod.:
    • TDD
      • PropEr ?
    • documents
      • curl usage ~ 3264b43
      • README ~
    • develop story
    • usage video

LICENSE

base MIT

THANKS

  • RIP/Joe Armstrong created Erlang
  • so José Valim can design Elixir

contribute

  1. Fork this repo.
  2. new Feat_xxx branch
  3. commit code
  4. new Pull Request

logging:

  • 201019 zoomquiet re-build README, public main branch
  • 201018 zoomquiet Refactor as Shortener
  • 201017 zoomquiet prototype
  • 201016 zoomquiet API design
  • 201014 zoomquiet init.
Elixir
1
https://gitee.com/alchemists/ziply.git
git@gitee.com:alchemists/ziply.git
alchemists
ziply
ziply
master

搜索帮助