2 Star 3 Fork 3

alchemy / ziply

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ziply

zip url like bitly/TinyURL/...

ShortEner

自己的缩址服务

安装

依赖 Elixir 1.9 以上环境,

参考 Installing Elixir - The Elixir programming language 完成本地环境安装,

$ elixir -v

可以看到类似:

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)

说明安装成功;

现在就可以将当前项目作为应用在本地运行起来了:

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

先 clone 仓库到本地; 然后创建数据库目录:

$ mkdir priv

现在目录结构应该形如:

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

$ cd ziply/short_ener

进入应用目录;

$ mix deps.get && mix deps.compile

下载并编译所有依赖模块;

$ mix run --no-halt

然后就可以运行了, 比如, 以 mix 持续运行状态, 可以看到类似输出:

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

就说明成功了..

使用

MVP 状态, 只提供最小三个功能

存活检验

$ curl localhost:9081/ping

echo:

pong ;-)
I'm alive.

生成短址:

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

如果是新地址:

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

如果是老地址:

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

缩址转发

用浏览器访问对应缩址即好

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

部署

推荐使用 mix release 工具

在目标主机中, 在可运行基础上,

$ cd path/2/u/ziply/short_ener

进入 clone 好的目录,

$ mix release.init

初始化 release

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

$ MIX_ENV=prod mix release --overwrite

然后编译为产品;

...
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

然后, 就可以看到类似提示, 先运行产品看看包含什么功能:

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

成功看到类似提示,说明 Elixir 已经准备好长期运营的编译了:

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

功能

支持和计划

  • 功能:
    • POST 接口
    • GET 接口
      • /
      • /ping
      • /ziplty: 302 跳转
      • 访问计数
    • SSL
  • 运维:
    • 发布绑定为 t.101.so
    • 访问统计
    • test case
    • 发布为 https
    • 管理接口加密/认证
    • Mnesia DBA
      • 备份
      • 迁移
      • 恢复
      • 分布
  • 产品化:
    • 测试
      • PropEr ?
    • 文档
      • curl 文案 ~ 3264b43
      • README 文案 ~
    • 故事
    • 视频

许可证

使用 MIT 许可证

感谢

  • RIP/Joe Armstrong 创造了 Erlang
  • 这才有 José Valim 灵感爆发的成果 Elixir ~ 万灵药

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

进展:

  • 201019 zoomquiet 增补文档, 提示发布 master
  • 201018 zoomquiet 重构为 Shortener
  • 201017 zoomquiet 原型完成
  • 201016 zoomquiet API 方案明确
  • 201014 zoomquiet init.
MIT License Copyright (c) 2020 ZoomQuiet Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

zip url like bitly/TinyURL/... 展开 收起
Elixir
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Elixir
1
https://gitee.com/alchemists/ziply.git
git@gitee.com:alchemists/ziply.git
alchemists
ziply
ziply
master

搜索帮助