我正面临一些关于tomcat启动和关闭的问题.
我在用
我使用命令启动tomcat:
$./catalina.sh jpda start
Run Code Online (Sandbox Code Playgroud)
然后我尝试使用命令停止它:
$./catalina.sh stop
Run Code Online (Sandbox Code Playgroud)
并获得以下消息:
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:351)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:213)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:200)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:529)
at java.net.Socket.connect(Socket.java:478)
at java.net.Socket.<init>(Socket.java:375)
at java.net.Socket.<init>(Socket.java:189)
at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:422)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:338)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:416)
Run Code Online (Sandbox Code Playgroud)
我也尝试使用命令停止它:
$./catalina.sh stop -force
Run Code Online (Sandbox Code Playgroud)
但我收到了消息:
Kill failed: $CATALINA_PID not set
Run Code Online (Sandbox Code Playgroud)
然后我再次尝试使用命令启动tomcat:
$./catalina.sh jpda start
Run Code Online (Sandbox Code Playgroud)
在/ logs文件夹中,仅生成catalina.out,并显示以下错误消息:
ERROR: transport error 202: bind failed: Address already in use …Run Code Online (Sandbox Code Playgroud) Ubuntu 12.04 LTS
Ruby ruby 1.9.3dev(2011-09-23修订版33323)[i686-linux]
Rails 3.2.9
以下是我收到的CSV文件的内容:
"date/time","settlement id","type","order id","sku","description","quantity","marketplace","fulfillment","order city","order state","order postal","product sales","shipping credits","gift wrap credits","promotional rebates","sales tax collected","selling fees","fba fees","other transaction fees","other","total"
"Mar 1, 2013 12:03:54 AM PST","5481545091","Order","108-0938567-7009852","ALS2GL36LED","Solar Two Directional 36 Bright White LED Security Flood Light with Motion Activated Sensor","1","amazon.com","Amazon","Pasadena","CA","91104-1056","43.00","3.25","0","-3.25","0","-6.45","-3.75","0","0","32.80"
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试解析CSV文件时,我收到错误:
1.9.3dev :016 > options = { col_sep: ",", quote_char:'"' }
=> {:col_sep=>",", :quote_char=>"\""}
1.9.3dev :022 > CSV.foreach("/tmp/my_data.csv", options) { |row| puts row }
CSV::MalformedCSVError: Illegal quoting in line 1.
from /home/jigneshgohel/.rvm/rubies/ruby-1.9.3-rc1/lib/ruby/1.9.1/csv.rb:1925:in `block (2 levels) …Run Code Online (Sandbox Code Playgroud) 环境
Rails 4.2.0
ruby-2.2.1 [ x86_64 ]
devise 3.4.1
rspec-core 3.2.2
rspec-rails 3.2.1
Run Code Online (Sandbox Code Playgroud)
在我的/spec/rails_helper.rb中,我已经为使用和标记的spec文件包含了Devise助手type: :controllertype: :request
投机/ rails_helper.rb
ActiveRecord::Migration.maintain_test_schema!
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = false
config.before(:suite) do
DatabaseCleaner.strategy …Run Code Online (Sandbox Code Playgroud) test_module.rb
module MyModule
def module_func_a
puts "module_func_a invoked"
private_b
end
module_function :module_func_a
private
def private_b
puts "private_b invoked"
end
end
class MyClass
include MyModule
def test_module
module_func_a
end
end
Run Code Online (Sandbox Code Playgroud)
从类调用模块函数
c = MyClass.new
c.test_module
Run Code Online (Sandbox Code Playgroud)
输出1:
$ ruby test_module.rb
module_func_a invoked
private_b invoked
Run Code Online (Sandbox Code Playgroud)
在类方法样式中调用模块上的模块函数
ma = MyModule.module_func_a
Run Code Online (Sandbox Code Playgroud)
输出2:
module_func_a invoked
test_module.rb:5:in `module_func_a': undefined local variable or method `private_b' for MyModule:Module (NameError)
from test_module.rb:31
Run Code Online (Sandbox Code Playgroud)
从输出1和输出2中可以看出,当将模块包含在类中时,当从模块函数调用模块的私有方法时,如果在类方法样式中直接调用模块上的模块函数,则不会出现问题找不到模块函数调用的模块私有方法.
任何人都可以让我理解上面行为背后的原因,是否可以在类方法样式中调用模块函数(进而调用模块的私有方法)?如果可能的话,我的代码中需要做哪些修正才能做同样的事情?
ruby 1.9.3dev(2011-09-23修订版33323)[i686-linux]
Rails 3.0.20
最近为什么在Rails上与DateTime相关的RSpec项目上我发现 在给定的日期,以下语句发出的值
date.end_of_day.to_datetime
Run Code Online (Sandbox Code Playgroud)
和
date.to_datetime.end_of_day
Run Code Online (Sandbox Code Playgroud)
当比较返回false时,虽然它们代表相同的日期时间.
为了确认这一点,我打开了Rails控制台并试用了以下内容
1.9.3dev :053 > monday = Time.now.monday
=> 2013-02-25 00:00:00 +0530
1.9.3dev :054 > monday.class
=> Time
1.9.3dev :055 > d1 = monday + 1.hour
=> 2013-02-25 01:00:00 +0530
1.9.3dev :056 > d2 = monday + 1.hour
=> 2013-02-25 01:00:00 +0530
1.9.3dev :058 > d1_eod_datetime = d1.end_of_day.to_datetime
=> Mon, 25 Feb 2013 23:59:59 +0530
1.9.3dev :059 > d2_eod_datetime = d2.to_datetime.end_of_day
=> Mon, 25 Feb 2013 23:59:59 +0530
1.9.3dev :061 …Run Code Online (Sandbox Code Playgroud) 我望着使用monit的工具,我的Rails app.As这是我第一次使用任何监视工具可以有人指导我或点我一些参考试图对我如何设置和使用的monit使用默认的Rails的WEBrick服务器工具(当地的发展环境)?我发现了以下引用,但它们都展示了针对Apache,Nginx等的monit配置.
环境:
谢谢,
Jignesh
环境
Ruby 2.2.1,Rails 4.2.0,rspec-core 3.2.2,rspec-expectations 3.2.0,rspec-mocks 3.2.1,rspec-rails 3.2.1,rspec-support 3.2.2
我有以下方法
def send_event_alert_email(event_id)
event = Event.find_by(id: event_id)
...
...
...
EventAlertMailer.event_alert(event_id).deliver_now
create_alert(event)
end
Run Code Online (Sandbox Code Playgroud)
我需要编写规范,以确保create_alert(event)在EventAlertMailer.event_alert(event_id).deliver_now引发任何异常时不会调用它.所以基本的问题是我如何模拟deliver_now以引发它可能实际抛出的可能异常.
我使用以下命令生成了一个基于 Rails 5 边缘版本的仅骨架 API 的应用程序:
rails app_name --api --edge
Run Code Online (Sandbox Code Playgroud)
它的Gemfile包括链轮和 SASS 宝石,可以在其中看到。
gem 'sprockets-rails', github: "rails/sprockets-rails"
gem 'sprockets', github: "rails/sprockets"
gem 'sass-rails', github: "rails/sass-rails"
Run Code Online (Sandbox Code Playgroud)
我只是想知道 Sprockets 和 SASS 应该在仅 API 的应用程序中发挥什么作用?是故意做的还是到 Rails 5 正式发布时,这应该是固定的。
我还观察到,在生成 Rails 应用程序时,生成器确实创建了资产文件夹,但稍后将其删除,如下所示的输出所示:
create app
create app/assets/config/manifest.js
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/jobs/application_job.rb
create app/views/layouts/application.html.erb
create app/assets/images/.keep
create app/mailers/.keep
create app/models/.keep
create app/controllers/concerns/.keep
create app/models/concerns/.keep
create bin
create bin/bundle
create bin/rails
create bin/rake
create bin/setup
create bin/update
create config …Run Code Online (Sandbox Code Playgroud) 我有以下Controller规范示例传入基于Rails 4.2.0和Ruby 2.2.1的仅API应用程序
let!(:params) { { user_token: user_token } }
context "- and optional address and contact details params value are received as a nil values -" do
it "doesn't set the address and contact details and responds with 201 success", check: true do
params.merge!(
address_street: nil, address_other: nil, city: nil, state: nil,
zip_code: nil, phone: nil)
post :create, params
expect(response).to have_http_status(201)
saved_client_id = json_response["id"]
saved_client = Client.find_by(id: saved_client_id)
expect(saved_client.address_street).to be_nil
expect(saved_client.address_other).to be_nil
expect(saved_client.city).to be_nil
expect(saved_client.state).to be_nil
expect(saved_client.zip_code).to …Run Code Online (Sandbox Code Playgroud) 我有一个需要使用插值动态创建unicode字符串的要求。例如,请参见以下在irb中试用的代码
2.1.2 :016 > hex = 0x0905
=> 2309
2.1.2 :017 > b = "\u#{hex}"
SyntaxError: (irb):17: invalid Unicode escape
b = "\u#{hex}"
Run Code Online (Sandbox Code Playgroud)
十六进制代码0x0905对应于DEVANAGARI字母A的独立元音的unicode。
我无法弄清楚如何达到期望的结果。
ruby ×4
ruby-2.2 ×2
actionmailer ×1
api ×1
csv ×1
datetime ×1
devise ×1
dynamic ×1
malformed ×1
module ×1
monit ×1
params ×1
rspec-rails ×1
rspec3 ×1
shutdown ×1
string ×1
tomcat6 ×1
ubuntu-10.04 ×1
ubuntu-12.04 ×1
unicode ×1