Jump to content

[Solved] Long-Running Process On Johnny


damnu

Recommended Posts

Hi there,

 

I have very small console application written in C#.NET.

This app checks email every 10 seconds and in case it finds a mail, this mail is parsed and processed...

 

Obviously, this app must run "forever".

 

Will this wiork with Johnny?

Link to comment
Share on other sites

Yes, it will probably run, but keep in mind that scripts that run constantly cause a lot of load. If you cause so much load that you begin to cause downtime or slow response time for the other users on your server your account will be suspended. It's usually better to use an external cron to run a short script every few minutes than have a script that never ends.

Link to comment
Share on other sites

Hi there,

 

I have very small console application written in C#.NET.

This app checks email every 10 seconds and in case it finds a mail, this mail is parsed and processed...

 

Is the mailbox hosted here? If so, you could also just configure the email address to pipe the mail directly into the processing script when it arrives.

Link to comment
Share on other sites

Thanks for your reply, guys!

 

The point is that 10 sec. is the bare min. frequency I want to check for new mails. Thus, a cron checking every minute is not sufficient.

 

Hosting the mMailbox here would not be a problem.I can simply Forward the mail upon arrival at the original mailbox.

But frankly speaking, I have no idea how to implement your suggestion of "piping the mail directly into the process script".

Link to comment
Share on other sites

Take a look at https://www.helionet.org/index/topic/28921-triggering-a-file-on-arrival-of-email/ (that person was using a Tommy account, but it works the same on Johnny as well, just change the server name in the URLs listed).

 

When the server receives the email, it launches a configured program (such as a PHP script), and uses the email itself as the input. This way, there's nothing running at all until an email is received. When the email is received, it's immediately processed, then the script exits. The mail server itself is monitor as opposed to running something repeatedly.

Link to comment
Share on other sites

An EXE won't run on our servers since we run linux. There's a difference between .NET PC software and ASP.NET (web software), we only support the latter. ASP.NET software is written differently, and generally comes in the form of .aspx files and dll files (depending on whether you compile it or not).

 

You'll need to develop the program you want to run in a form our server can handle before you worry about email triggers. Can you write the email processing code in something like PHP/Python/Perl? The "monitor" component that watches the mailbox is not needed and should be left out. The mail server will handle that for you.

Link to comment
Share on other sites

I know that .NET binaries compiled on a Windows PC can run on Linux provided that MONO is installed and that the binary does not contain references to "non-MONO-libraries" or native Windows calls.

So you are saying MONO is not installed?

 

Funny enough, when I developed the initial version of my program, I did this in perl. After some versions, I went for C#...

Not sure if I want to go back to perl again.

Link to comment
Share on other sites

Mono is installed. I've never tried running one personally, but nobody has ever tried running a .NET EXE on our servers since it's an odd thing to do on a shared host. Our root admin Krydos would know for sure, so I'll escalate this.

 

 

Link to comment
Share on other sites

@damnu a script in perl/PHP/python will be more secure than anything that mono emulates

 

You can you the script mentioned above to write the mail to a file that you can then process with your asp.net files (or whatever) which can be called externally with a service like https://cron-job.org

 

I believe the admins offer a similar service to call a script externally.

Link to comment
Share on other sites

I believe the admins offer a similar service to call a script externally.

We do, though since his goal is to process emails as they arrive, it's easier and lighter on resources to just have the mail server directly hand the email to the script when it arrives, as opposed to having the mail server save the mail in the mailbox and constantly watching the mailbox to grab the mail out of it.

Link to comment
Share on other sites

I stand by my original statement:

Yes, it will probably run

That said, it's always wise to use the right tool for the job. Sure, you can probably use a chainsaw to shave your legs if you're really good at chainsawing things, but it's probably not the best tool for the job. Running a windows binary executable on a linux server in a constant loop to check a mailbox every 10 seconds is the chainsaw in my opinion. It might work, but it's kind of ridiculous.

 

Actually, one of perl's strengths is regular expression matching which makes it quite powerful when processing strings, and extracting data from text. When you pipe an email to a script it passes it via stdin which is basically just a big wad of text. Perl would be an excellent choice in my opinion for this project. Let us know if you need help with any of it even if you decide to go with the .exe file.

Link to comment
Share on other sites

I absolutely agree with you guys!

Having the mail daemon trigger the script is a much smarter way.

 

An initial test with a small perl script worked but am wondering how to properly debug the script the mail is piped through to??

 

Right now, emails I sent are not delivered to the inpox nor can I see them being piped throught to my script. I am sure that my script is the cause for that since I more or less just copied some stuff from other scripts I have written before...

When no error messages are coming back it is hard to tell where to start...

Link to comment
Share on other sites

When I debug a script that has mail being piped to it I use log files to debug it. Like have the script write variables and whatnot to a file, and then run an email through it and then see what is in the log file.

 

Right now, emails I sent are not delivered to the inpox

Did you catch this line in my guide?

If you want the email to be delivered to your inbox in addition to piping to your script you can click the + on the right side, and set up Deliver to Folder: Inbox. This way it'll pipe it to your script AND put it in the inbox.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...