Ubuntu Linux – Disk Full 100% What to do?
When the DISK is full – lot of things stops functioning.
Here is a way to find and clear the log files.
1) Check the Disk Usage using sudo df -h
testserver: sudo df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda 30G 746M 30G 100% /
tmpfs 513M 0 513M 0% /lib/init/rw
varrun 513M 56K 513M 1% /var/run
varlock 513M 0 513M 0% /var/lock
udev 513M 108K 512M 1% /dev
tmpfs 513M 0 513M 0% /dev/shm
2) Finding the largest size FOLDER
sudo du -hc –max-depth=1 /
201M /var
118M /home
2.9M /etc
4.0K /tmp
4.0K /media
4.0K /boot
4.9M /sbin
28K /root
4.0K /mnt
108K /dev
4.0K /srv
4.0K /selinux
336M /usr
12M /lib
0 /sys
4.9M /bin
4.0K /opt
1.1G /proc
16K /lost+found
1.7G /
1.7G total
Mostly you will fine the issue with the log files in /var/log folder
3) Clearing the log files
Go to bash
testserver: sudo bash
go to the problem folder
testserver: cd /var/log
testserver /var/log: ls -l
Go to bash and run the command > mail.log (NOTE: greater than symbol followed by the file name)
This will override the file with blank by keeping all the permissions of the file intact!
testserver /var/log: > mail.log
testserver /var/log: > mail.info
testserver /var/log: > syslog
you can also do – sudo cat /dev/null > /var/log/syslog
SOAP4R and ActionWebServices Conflicts and the FIX
SOAP4R and ActionWebServices doesn’t get along very well – due to conflicts in their naming convention.
SOAP4R is used to connect to any Web Services based third party clients – may or may not be based on rails. SOAP4R works fine when its used independently.
If you have to offer your own Web Services using ActionWebServices – independently it works fine without SOAP4R being used.
When used together – the following exception is thrown – when wsdl URL is accessed related to your ActionWebServices!
NameError (uninitialized constant SOAP::XSDNamespaceTag):
/vendor/rails/activesupport/lib/active_support/dependencies.rb:442:in `load_missing_constant’
/vendor/rails/activesupport/lib/active_support/dependencies.rb:77:in `const_missing’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/protocol/soap
protocol/marshaler.rb:160:in `qualified_type_name’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/dispatcher/ac
ion_controller_dispatcher.rb:231:in `to_wsdl’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/support/signa
ure_types.rb:205:in `each_member’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/support/signa
ure_types.rb:204:in `each’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/support/signa
ure_types.rb:204:in `each_member’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/dispatcher/ac
ion_controller_dispatcher.rb:229:in `to_wsdl’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `call’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `_nested_structures’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:58:in `method_missing’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/dispatcher/ac
ion_controller_dispatcher.rb:228:in `to_wsdl’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `call’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:134:in `_nested_structures’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/builder-2.1.2/lib/builder/xmlbase.rb:58:in `method_missing’
D:/s/InstantRails/ruby/lib/ruby/gems/1.8/gems/datanoise-actionwebservice-2.2.2/lib/action_web_service/dispatcher/ac
ion_controller_dispatcher.rb:227:in `to_wsdl’
You must have already included gem ’soap4r’ to make your WebServices Client code working.
To fix this problem … add the following code to your environment.rb file and restart your server. Now both should be working.
module SOAP
SOAPNamespaceTag = ‘env’
XSDNamespaceTag = ‘xsd’
XSINamespaceTag = ‘xsi’
end
How to install and configure Postfix in Ubuntu
Postfix is the default Mail Transfer Agent (MTA) in Ubuntu. It attempts to be fast and easy to administer and secure. It is compatible with the MTA sendmail. This section explains how to install and configure postfix. It also explains how to set it up as an SMTP server using a secure connection (for sending emails securely).
Installation
To install postfix run the following command:
sudo apt-get install postfix
Simply press return when the installation process asks questions, the configuration will be done in greater detail in the next stage.
Basic Configuration
To configure postfix, run the following command:
sudo dpkg-reconfigure postfix
The user interface will be displayed. On each screen, select the following values:
-
Ok
-
Internet Site
-
NONE
-
mail.example.com
-
mail.example.com, localhost.localdomain, localhost
-
No
-
127.0.0.0/8, 192.168.0/24
-
Yes
-
0
-
+
-
all
How to reconfigure Postfix?
Once Postfix is installed, reconfiguration can be done using the following command.
sudo dpkg-reconfigure postfix
The user interface will be displayed. On each screen, select the following values:
-
Ok
-
Internet Site
-
NONE
-
mail.example.com
-
mail.example.com, localhost.localdomain, localhost
-
No
-
127.0.0.0/8, 192.168.0/24
-
Yes
-
0
-
+
-
all
You may have to edit /etc/postfix/main.conf to update the mail hostname!!
Learning HTML5 and CSS3 by example
Check out an excellent presentation & Live Demo – written in HTML5, CSS3 and JS APIs for demonstrating the capabilities of HTML5, CSS3 and JS APIs.
Check it out …
http://apirocks.com/html5/html5.html
Introduction to HTML5 & CSS3
Canvas Demos
Checkout the DEMOs here …
http://www.canvasdemos.com/type/applications/
http://code.edspencer.net/Bean/index.html
http://www.xarg.org/project/chrome-experiment/
http://www.canvasdemos.com/2010/05/06/catch-it/
SVG Demos
http://code.google.com/p/svgweb/
http://codinginparadise.org/projects/svgweb/samples/demo.html
http://codinginparadise.org/projects/svgweb/samples/javascript-samples/svg_dynamic_fancy.html
Geo-Location Demo
http://www.mozilla.com/en-US/firefox/stats/
jQTouch Demo
http://jqtouch.com/preview/demos/main/
Finally, an excellent Demo on all the latest features from HTML5, CSS and the JavaScript APIs, This presentation itself is an HTML5 one page website.
http://apirocks.com/html5/html5.html
Some screens from the Demo:
Installing Passenger passenger-install-apache2-module: command not found
If you are installing/upgrading Phusion Passenger (a.k.a mod_rails/mod_rack) and facing the following error at the second step when you run passenger-install-apache2-module
sudo: passenger-install-apache2-module: command not found
That means gems bin directly is no in the PATH. Either you can add this to the PATH or You can simply run the command with the full path to passenger-install-apache2-module.
In our case, we use enterprise ruby and the command looks like as below:
sudo /opt/ruby-enterprise-1.8.7-2010.01/bin/passenger-install-apache2-module
You can find the bin path to the gems by issuing the following command – note the bold blue text:
server5 ~: gem environment
RubyGems Environment:
– RUBYGEMS VERSION: 1.3.5
– RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux]
– INSTALLATION DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8
– RUBY EXECUTABLE: /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby
– EXECUTABLE DIRECTORY: /opt/ruby-enterprise-1.8.7-2010.01/bin
– RUBYGEMS PLATFORMS:
– ruby
– x86_64-linux
– GEM PATHS:
– /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8
– /home/username/.gem/ruby/1.8
– GEM CONFIGURATION:
– :update_sources => true
– :verbose => true
– :benchmark => false
– :backtrace => false
– :bulk_threshold => 1000
– :sources => ["http://gems.rubyforge.org/", "http://gems.github.com"]
– REMOTE SOURCES:
– http://gems.rubyforge.org/
– http://gems.github.com
Upgrading to Phusion Passenger 2.2.11
When under high load, Apache was freezing and stop responding to requests in 2.2.10 & 2.2.9 version of Passenger.
More information about the problem can be found at the following discussion thread:
http://groups.google.com/group/phusion-passenger/t/d5bb2f17c8446ea0
Its worth while to upgrade to the latest version of Phusion Passenger 2.2.11
How to upgrade to 2.2.11?
Via a gem
Install it with the following command:
gem install passenger
Next, run:
passenger-install-apache2-module
Or, if you’re an Nginx user:
passenger-install-nginx-module
On successful installation – you will see something like – for Apache:
The Apache 2 module was successfully installed.
Please edit your Apache configuration file, and add these lines:
LoadModule passenger_module /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11/ext/apache2/mod_passenger.so
PassengerRoot /opt/ruby-enterprise-1.8.7-2010.01/lib/ruby/gems/1.8/gems/passenger-2.2.11
PassengerRuby /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby
After you restart Apache, you are ready to deploy any number of Ruby on Rails
applications on Apache, without any further Ruby on Rails-specific
configuration!
Copy & paste the above three lines into Apache config /etc/apache2/conf.d/passenger and restart the Apache /etc/init.d/apache2 restart server..
For further details – http://blog.phusion.nl/2010/03/05/phusion-passenger-2-2-11-released/
Deserializing an object failed in ActiveRecord
This can happen when the rails dependency system doesn’t load the serialize referenced objects before deserialize happens. We killed some time figuring this out – here is what you can do if you see any such issue:
For example:
The following code could create deserialization errors when Employee object is loaded.
class Employee < ActiveRecord::Base serialize :job_roles
belongs_to :company
end
class JobRole attr_accessor :role_type, :job_role, :description def initialize(role_type, job_role, description)
@job_role= job_role
@role_type= role_type
@description = description
end ...... end
You can fix this issue either by loading JobRole class in environment.rb or just load it in the respective ActiveRecord class itself.
class Employee < ActiveRecord::Base
JobRole
serialize :job_roles
belongs_to :company
end
Ruby on Rails: Serializing and DeSerializing Ruby objects
Serialization in Ruby comes very handy at times, it really helps in several cases especially when dealing with:
- persisting Ruby objects onto a disk or to the database
- transferring the Ruby objects over the network
- session persistence
- complex data structure storing in the database with ActiveRecord
- and lot more …
The Object Serialization can be done in Ruby in two ways and its directly built into the language itself, and its quite straight forward to use this. One is Binary Serialization, where the object will be serialized to a Binary Format and the Other One is Human-Readable Serialization using YAML. Apart from this you can use third party libraries like JSON serialization too – which needs bit more setup, coding etc.
Here will cover the default Ruby serialization mechanisms:
Binary Serialization
This is achieved using the Marshal class.
class Hello def initialize(str) @str = str end
def sayHello @str end end
hello = Hello.new("Hello World")
puts hello.sayHello
# Serialize using Marshal.dump - Binary serialized_object = Marshal.dump(hello)
# DeSerialize using Marshal.load
hello = Marshal.load(serialized_object)
puts hello.sayHello
Result:
Hello World
Hello World
We cannot make out any meaningful content from the serialized object, hence its not shown here.
As you notice above the values printed are same after serialization and de-serialization using the Binary mechanism using the Marshal class.
Use this:
- when you want a high performance serialization and de-serialization process
- when you do not need to read the contents of the serialized object
Human-Readable Serialization
Lets use the same Hello class as defined above. This is achieved using the built it YAML class, and its very straight forward to use.
require ‘yaml’
hello = Hello.new("Hello World")
puts hello.sayHello
# Serialize using YAML.dump – Human Readable serialized_object = YAML.dump(hello)
puts serialized_object
# DeSerialize using YAML.load hello = YAML.load(serialized_object)
puts hello.sayHello
Result:
Hello World
— !ruby/object:Hello
str: Hello World
Hello World
As you can notice the serialized object is Human Readble format.
Use this:
- when you really need to have the serialized object contents in the human readable format
- at the cost of performance impact in serialization and de-serialization process
- to save into the files and send across the YAML serialized files over the nework
Another alternate Human-Readable serialization is via JSON.
You will have to install the following Gems and write the necessary code to serialize into JSON objects and de-serialize to create the Objects.
gem install json-pure
OR
gem install json
Look our for an other article on how to use JSON for serialization.
Similarly you can also do Human-Readable serialization is via XML.
ActiveRecord Serialization Support
Active Records support different types of serializations.
JSON, XML and YML serializations are supported by the ActiveRecords.
Default serialization method used by Rails is YML.
class Employee < ActiveRecord::Base serialize :job_roles
belongs_to :company
end
class JobRole attr_accessor :role_type, :job_role, :description def initialize(role_type, job_role, description)
@job_role= job_role
@role_type= role_type
@description = description
end ...... end
Here the serialize converts the job_roles array into YAML before saving to the database and de-serializes the YAML string into an Array of JobRole objects on loading from the database.
Quite useful when storing complex data structures.
Pit Falls:
Not advised to store big serialized objects – as it can have major performance impact.
Do your tests for performance and scalability before you use it.


