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
支持和计划
使用 MIT 许可证
RIP
/Joe Armstrong 创造了 Erlang此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
1. 开源生态
2. 协作、人、软件
3. 评估模型