Mochiweb mnesia requests - erlang

I'm trying to link Mochiweb with my ejabberd mnesia db and am unable to do any mnesia transactions in my controllers. I test my controllers without the mnesia transactions and they work fine. I am using application:start(mnesia) inside the start function.
On the browser, I see "Internal server error" and on Mochiweb's log I see, "=ERROR REPORT=== function_clause". I'd like to know how to either 1.) get mnesia to work with Mochiweb or 2.) what a good framework I could plugin to ejabberd's web server is.
Thanks!

Do you have the rest of the error message from Mochiweb's log - the bit after "function_clause" if it has it?

This must be an error within your code. Last time I checked the mochiweb source it wrapped your "loop" function within a try catch. If it caught an exception, it printed the type of that exception to the error log; in your case you have a function_clause exception.
Either try calling your loop function manually, or wrap your code in yet another try catch to be able to see the whole exception. If you can't decipher it, paste it to your question please.

You know, I think I was doing it all wrong... I was thinking it would work like PHP/SQL and Rails/SQL, but it seems the best way to do this is calling methods from the Mochiweb node to the ejabberd node.
Also I noticed that when I started Mochiweb connected to the same mnesia database as ejabberd, it tried to "repair" some of my tables - basically erasing everything.
If anyone has any input on this (or if I'm totally off) please let me know. Thanks!

Related

Detect "Delay write failed" occurence

I am loosing my patience with "delay write failed" errors. It silently disconnects the database from the application so nothing gets saved in the database while using it. Is there a way to detect the occurrence itself so I can flash a warning ? Or perhaps monitoring the connection itself for a disconnection ? Everyone seems to miss the balloon tip from the Windows XP so I figured to flash a more visible warning that the application must be restarted. It seems Microsoft has found a way to force people to upgrade....
I suppose this could be done with a timer and constantly check connected users:
cxlabel1.Caption := IntToStr(DataModule2.ABSDatabase1.GetDBFileConnectionsCount);
But I was thinking more of checking/detecting for the occurence itself. Is there something in Delphi that can detect this?
I would like to hear your ideas on this...
Putting this as an answer because the comment length is limited.
I have seen this before. IIRC, the problem you have is that the Delayed Write Error is an OS error, it has nothing to do with your application. Windows has already told you that the write has been committed correctly to disk. You would have to try and hook into the OS errors to see when this is happening.
You need to get the network issues resolved because that's where the problem is. In our situation it was a faulty router that was causing the problem.
It's unfair to expect users to check for the error message and then handle it. They could be out at lunch when it occurs as it's not immediate. They also have no way of know what has been saved and what hasn't. It's only a matter of time before your database is corrupted.
The problem with a timer is that it might tell you everything is fine because it triggers after the network resolves the problems.
A far better approach would be to switch to a Client/Server database. You can do this by setting up your own server that listens for web service or another remote call or switch to a database that supports client/server instead of using a file based database. This will tell you immediately when there is a problem with the save of data.

Nodes timing out in umbraco back-end

I'm having an issue with an umbraco site of mine: For some reason some of the nodes are timing out when I try to click on them in the back-end of the site.
The front-end works fine and there aren't any slowdown issues there, however I'm unable to edit these same nodes in the back-end as the system seems to just hang. This is making it incredibly difficult to debug as I have no idea what properties are actually causing the problems here. What's strange is I can create a node of the same document type and enter in some dummy values and that works fine, yet I can't seem to edit the existing nodes.
I've tried republishing the entire site, republishing the individual nodes, deleting the umbraco.config file and nothing has worked up to this point.
What's also interesting is that if I close down the browser the system seems to stop hanging and I can log in and try again.
Has anyone encountered this before or know where to begin?
Thanks
I have encountered something similar. The longer you work with Umbraco the slower it becomes and if you check the memory usage in Chrome's task manager, you can see that certain actions upon nodes bump the memory usage up a little further. The answer is just to close down the tab and open a new one.
I have reported this and Umbraco cannot replicate this. However, I do think that this is possibly due to maybe a package installed into Umbraco, maybe uComponents. It's very difficult to pin point.
Update:
If you can access some nodes but not others, then this is actually slightly easier to debug. I would check what similarities the nodes that timeout have.
Are they all of the same document type?
Do they all use the same data type?
I would guess that the nodes in question are using a data type that is performing an operation when the node is loading, and that operation is timing out. For example, do you have any data types that load data from the database, like enums? Do you have any datatypes that load data from a web service?
Do you have any usercontrol data types wrapped in the UserControlWrapper data type? These would be somewhere to check.
Finally, check:
The databases [umbracoLog] table. Any Umbraco-specific errors will be listed there.
Check the computer's event viewer. This will show any unhandled errors.
My money's on a database timeout.

What is the best way to make a Windows service ask the user for input?

I'm trying to write a program to ask me to input some information periodically, so I've written a service in C to run in the background, I can watch it reporting its okay by refreshing its log file. Now I'm stuck on how to get it to open up cmd and ask for the information.
I'd like to save this information to a log file. (I'm planning on monitoring my sleeping habits)
I tried using system("getinput.exe") and that seems to do nothing, I know using system() is bad but it was a first step.
CreateProcess() I simply cannot get to work, the example on MSDN http://msdn.microsoft.com/en-us/library/ms682512.aspx doesn't work for me, i just get CreateProcess failed (2) whenever i try createprocess.exe dir for example.
Surely there must be a way?
EDIT: Thanks for the replies I will try to take a different approach then. Where would I start with writing a background application that can occasionally ask for user input in C?

advanced mode for errors displaying during development right in browser (Ruby-on-Rails)

it would be nice to see some additional info about exceptions just in browser. not only exception itself with few lines of code and not necessary (for me during development) stack traces but, for example, sql and, maybe, some more info - like exact place of problem in looong line of code (it is possible, i guess). it would be very helpful to see exact objects (truncated if it would be long) instead of Array:0x00000103e26ea0 in
undefined method `name' for #<Array:0x00000103e26ea0>
even additional info from log would be nice to see right in browser without switching to log every time
any tricks (gems, monkey-patches) on this?
in other words: what do you use to pleasurify (is this word exists?:)) development process?
thanx in advance
In addition to the development log (which includes your SQL errors) you might take a look at Hammertime or Pry, both of which are good debuggers that let you inspect your code more carefully around an exception.

Core dump equivalent for the Rails exception

So I got an exception log from my application. I have a call stack, request parameters and all other usual stuff in that log. This is a rare exception and info from the log doesn't contain all details I need to resolve / duplicate the problem.
I wonder if there is some way (gem?) to get full dump of Rails application state in case of an exception. Including all instance and local variables values from a controller methods. I guess that dump of whole Ruby object space might take even a minute or so but I don't care about disk and cpu resources in a such case.
I don't think so, the way I go about trying to do something like that is by using logger.error on the variables that i need more on info on.
If possible, it's also not a bad idea to try running it with ruby-debug (instructions here). All you would need to do is insert a call to debugger right before the error would be triggered or stick it in a rescue clause.
I am unaware of any method to get the application state.
One thing I do upon occassion is install netbeans which has a graphical debugger. You can hover over variables to see their values, easily walk the stack, and also have the exception trigger the debugger, rather than a breakpoint.

Resources