运行Elixir应用程序的正确方法是什么?
我正在创建一个简单的项目:
mix new app
Run Code Online (Sandbox Code Playgroud)
然后我可以这样做:
mix run
Run Code Online (Sandbox Code Playgroud)
这基本上编译了我的应用程序一次.所以当我添加:
IO.puts "running"
Run Code Online (Sandbox Code Playgroud)
在lib/app.ex我看到的"running"仅是第一次,每次连续run做什么,除非有一些变化.生成后我可以做什么app.app?
我当然知道我能做到:
escript: [main_module: App]
Run Code Online (Sandbox Code Playgroud)
in mix.exs,提供def main(args):然后:
mix escript.build
./app
Run Code Online (Sandbox Code Playgroud)
但在我看来,它有点麻烦.
还有类似的东西:
elixir lib/app.exs
Run Code Online (Sandbox Code Playgroud)
但它mix.exs显然不算数,这是我的依赖所需要的app.
当我输入
cap production deploy
我明白了
Capfile locked at 3.1.0, but 3.2.0 is loaded
当我卸载时,capistrano 3.2.0我得到了
Could not find capistrano-3.2.0 in any of the sources
Run `bundle install` to install missing gems.
Run Code Online (Sandbox Code Playgroud)
我的gemfile有
gem 'capistrano', '~> 3.1'
gem 'capistrano-rails', '~> 1.1'
Run Code Online (Sandbox Code Playgroud)
和Capfile
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
Run Code Online (Sandbox Code Playgroud)
在那种情况下该怎么办?
我有以下课程ModuleWithHttp:
@Injectable()
export default class {
constructor(private fetchApi: FetchApi) {}
}
Run Code Online (Sandbox Code Playgroud)
我想用它如下:
@Component({
selector: 'main',
providers: [FetchApi]
})
export default class extends ModuleWithHttp {
onInit() {
this.fetchApi.call();
}
}
Run Code Online (Sandbox Code Playgroud)
因此,通过扩展已经注入依赖项的超类,我想在其子代中访问它.
我尝试了许多不同的方法,甚至将超类作为组件:
@Component({
providers: [FetchApi]
})
export default class {
constructor(private fetchApi: FetchApi) {}
}
Run Code Online (Sandbox Code Playgroud)
但是,即使是在超级阶层,this.fetchApi也是null如此.
当我跑步时,cap production deploy我得到了cannot create directory ‘/var/www/application/repo’: Permission denied.
到目前为止,我已经创建了部署用户:
adduser deploy
adduser deploy sudo
Run Code Online (Sandbox Code Playgroud)
我在Capistrano中使用此用户.
实际上,当我登录时,默认情况下deploy@my.vps.ip我没有sudo权限,每次我需要明确启用它时sudo su.
我看到两种可能的解决方案
不幸的是,我不知道如何做到这两件事.
我是Rails的初学者,我有ActiveRecords关联的问题.
我正在创建简单的汽车租赁服务,我做了以下协会:
class Client < ActiveRecord::Base
has_many :rentals
has_many :bookings
has_many :cars, :through => :rentals
has_many :cars, :through => :bookings
end
class Rental < ActiveRecord::Base
belongs_to :client, dependent: :destroy
has_one :car
end
class Booking < ActiveRecord::Base
belongs_to :client, dependent: :destroy
has_one :car
end
Run Code Online (Sandbox Code Playgroud)
我需要的是拥有属于许多预订和租赁的汽车,而每个预订和租赁只能分配一辆汽车.
class Car < ActiveRecord::Base
# belongs_to_many :bookings
# belongs_to_many :rentals
end
Run Code Online (Sandbox Code Playgroud)
我该怎么办?
我想知道哪种方式更好地将图像存储在内存中:
BLOB要么
哪种方式更有效?我认为存储文件的路径需要更多操作,因为我们需要引用DB然后再提交文件,但我不确定这是否比将整个图像保存在DB中要差一些.
我正在构建一个基于六边形架构的Rails应用程序.
我的一个适配器是存储适配器(作为gem维护),它管理对数据库的访问,并为rails应用程序提供了简单的接口,以便在数据库中存储和查询数据.
我想ActiveRecord在这个gem中使用所有rake任务(创建,迁移,删除,回滚)来管理数据库.
我如何在轨道外使用AR,但是所有的rake任务?
ruby activerecord ruby-on-rails rails-postgresql ruby-on-rails-4
Google建议现在使用它Google Play Services来管理用户位置.但是,我们如何使用此API检查设备中是否打开了GPS,或者我们是否还有GPS连接?
在com.google.android.gms.location.LocationListener我们只有一个方法abstract void onLocationChanged(Location location),当位置发生变化时调用,但我们不知道有什么关于GPS状态.
怎么使用Google Play Services像"老" LocationManager和LocationListener?
我正在开发一个库和一个使用这个库的应用程序.
我没有这个库的任何远程存储库,它只作为常规项目存储在GitHub上.
在我的应用程序中,我想使用这个库作为依赖,我正在考虑的是有这样的结构:
.
??? README.md
??? project.clj
??? repo
??? src
??? target
??? libraries
? ??? my-library
??? test
Run Code Online (Sandbox Code Playgroud)
其中my-library是git submodule与我的图书馆.如何让我的应用程序知道这种依赖?
2016年的解决方案是什么?
activerecord ×2
android ×2
capistrano ×2
deployment ×2
angular ×1
associations ×1
clojure ×1
containers ×1
docker ×1
elixir ×1
gps ×1
leiningen ×1
location ×1
lxc ×1
maven ×1
ruby ×1
sqlite ×1
sudo ×1
ubuntu ×1
vps ×1