[Mongrel] Win32 service - Errno::EINVAL (Invalidargument)whenuploading image file

Luis Lavena luislavena at gmail.com
Sun Apr 29 01:18:53 EDT 2007


On 4/29/07, Herryanto Siatono <herryanto at gmail.com> wrote:
> Without your step through, I wouldn't have found it, thanks anyway!
>
> Btw, isn't it a bit harsh to throw an error when puts is called in mongrel
> service? Coz sometimes the 'puts' was called by core library, eg. This case
> the Base64.
>

Well, thats a design flaw, from mongrel_service I must admit, and from
Windows Services too (I'm 100% responsible for this).

Is not the service who thow it, is the ruby interpreter that tried to
write to the standard Out, even if they don't have a valid console
attached.

One workaround is replace ruby.exe with rubyw.exe, which ignores
everything that is console related, but found that brakes the new
service implementation (WiP, not in repository).

> Right now, I'm applying a patch to my app to ignore the stderr/stdout, and
> the app works fine now:
>
> class StdOutLogger
>   def write(s)
>        # do nothing
>     end
>   end
> end
>
> before_filter {
>   $stdout = $stderr = StdOutLogger.new
> }
>
> Was wondering, if there's variable to call to find out if the code is
> running on mongrel_service? So I can do simple filtering only to ignore
> sterr/out when running as a service.
>

The safer solution is redirect STDOUT and STDERR from ruby:

STDOUT.reopen("c:/path/to/log/file.log")

> If not is there a way to pass a variable when starting mongrel_service? I
> tried
> mongrel_service console single -c
> d:/rubywork/[appname]MONGREL_TYPE='service'
>

Currently there isn't. Adding environment variables prior starting
child process is currently in my TODO for new service implementation.

Also, the STDOUT/ERR problem (ala, puts) will be solved too. Must
tweak a few things with x64 platforms and do some testing.

> But no luck! :)
>

I know, I know, shame on me :-P

Regards and good weekend.

-- 
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard effort,
which is the price which all of us must pay to achieve any goal that
is worthwhile.
Vince Lombardi


More information about the Mongrel-users mailing list