智能瘦启动与 bash 的端口别名
我想要一个启动我的本地开发服务器的别名(ts)。该脚本应测试从 3000 开始的开放端口并使用第一个可用端口。此外,某些站点需要rackup文件,因此需要-R config.ru。此脚本应检查当前目录中的 config.ru 文件并将其添加到别名(如果存在)。
目前,为了启动我的本地开发环境,我运行:
alias ts="thin -R config.ru -p 3000 start"
通常,我需要运行多个服务器来测试不同的站点,因此我创建了额外的别名:
alias ts1="thin -R config.ru -p 3001 start"
i would like a single alias (ts) which starts my local development server. the script should test for an open port starting at 3000 and use the first available port. additionally, some sites require a rackup file, making -R config.ru necessary. this script should check the current directory for the config.ru file and add that to the alias if present.
currently, to start my local development environment, i run:
alias ts="thin -R config.ru -p 3000 start"
often, i need to run several servers to test different sites, so i've created additional aliases:
alias ts1="thin -R config.ru -p 3001 start"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,你可以做一些聪明的事情,使用 netstat 和类似的命令查看已经绑定了哪些端口,
但是如果你不关心丑陋的控制台垃圾邮件,你可以继续尝试端口,直到你得到这样的端口
Well, you could do something clever and look at what ports are already bound using netstat and a command like
but if you don't care about the ugly console spam you can just keep trying ports until you get one like this