Using Celery with Pylons - pylons

I am trying to set up celery and pylons and can't seem to get it working. I downloaded pylons-celery, but how do I point my Pylons environment to where the celeryconfig.py is? I placed the config file in my pylons-app\celery folder. I read this post, but it doesn't mention how to pair celery with pylons.. Any pointers are appreciated - thanks!

The tightest integration with pylons is to build a custom loader into paste commands. This is what celery-pylons does. Check out my fork of celery-pylons which should work with the latest celery and pylons 1.0.
To get the celeryd side working you need to add the correct options in your ini file and then call paster celeryd development.ini
For the webapp side you just need to import celerypylons in environment.py Then you will be able to import and use your tasks from anywhere in your project.

I'm not exactly sure what you're trying to achieve, but I'll explain how I just setup Pylons to work with celery and hopefully you can gain something from it.
My setup is fairly simple. I implemented a REST API with Pylons using a single controller called jobs. When a POST request is received, the controller action would submit a new task to celery, capture the new tasks's uuid, and respond to the original request with the uuid. I originally place my celeryconfig.py file in my controllers directory, but once I deployed the pylons app egg to the apache web server, the celeryconfig.py was no longer automatically found.
To remedy this, I created a celery directory at the same level as the model and controllers directories, and I placed my celeryconfig.py file there, along with an empty init.py.
Here is a snippet of code from jobs controller where I connect to celery and submit a new task.
from celery import Celery
from my_pylons_app.celery import celeryconfig
celery_app = Celery()
celery_app.config_from_object(celeryconfig)
result = celery_app.send_task("process_job", [job_guid], connect_timeout=10)
I was able to get this working with both my internal paste web server and my public live apache2 web server.

Related

How to enable caching in ArangoDB via Docker or arangojs?

I would like to enable caching in ArangoDB, automatically when my app start.
I'm using docker-compose to start the whole thing but apparently there's no simple parameter to enable caching in ArangoDB official image.
According to the doc, all the files in /docker-entrypoint-initdb.d/ are executed at container start. So I added a js file with that code:
require('#arangodb/aql/cache').properties({mode: 'on'});
It is indeed executed but caching doesn't seem to be enabled (from what I see with arangosh within the container).
My app is a JS app using arangojs, so if I can do it this way, I'd be happy too.
Thanks!
According to the performance and server config docs, you can enable caching in several ways.
Your method of adding require("#arangodb/aql/cache").properties({ mode: "on" }); to a .js file in the /docker-entrypoint-initdb.d/ directory should work, but keep an eye on the logs. You may need to redirect log output with a different driver (journals, syslog, etc.) to see what's going on. Make sure to run the command via arangosh to see if it works.
If that's a bust, you might want to see if there is a way to pass parameters at runtime (such as --query.cache-mode on). Unfortunately, I don't use Docker Compose, so I can't give you direct advice here, but try something like -e QUERY.CACHE-MODE=ON
If there isn't a way to pass params, then you could modify the config file: /etc/arangodb3/arangod.conf.
And don't forget about the REST API methods for system management. You can access AQL configuration (view and alter) in the Web UI by clicking on the Support -> Rest API -> AQL.
One thing to keep in mind - I'm not sure if the caching settings are global or tied to a specific database. View the configuration on multiple databases (including _system) to test the settings.

Using Cloud Code with the Parse Server and Heroku

I am trying to understand the new Parse Server and have deployed on Heroku. This went smoothly but what I am struggling with is figuring out how to write server side code (Cloud Code). I've read over the parse server example many times so I must be missing something but I'm very unclear if I should be using Express for something, or how I even begin to include my Cloud Code files. Any help is very much appreciated.
UPDATE:
I found the cloud folder I was just looking in the wrong place. I moved it and index.js to my apps folder on the desktop. I have changed the default code in main.js to my custom code. I have set up index.js with my apps information. The problem now is when I run the app and try to call the cloud code functions I get error invalid function.
If you have the parse server example running on heroku you are 90 percent there. Just open the cloud/main.js file and start adding your cloud code. There should be a hello cloud function there as an example.
To use your already created cloud code modules/files you can require them as you have done before on parse.com. The only difference is that the path should now be relative instead of absolute. For example require('cloud/cloudFunctions'); should be require('./cloudFunctions'); if you had a module called cloudFunctions.js in the cloud directory.
Cloud Code works similar to how it did on parse.com and you shouldn't have to think too much about expressjs for simple applications. That said, parse server is using expressjs so yes you are using it.
Parse server is simply a another node module similar to the other thousands available. If you do not have previous experience with nodejs, running parse server can seem complicated. Therefore I would recommend reading about the basics of nodejs before a full migration.
I'm using the Bitnami stack on a Google Compute Engine instance and I had a similar problem to yours. To solve it, just navigate to the folder where your server.js file is and create a folder called "cloud". Then create the main.js file inside the cloud folder with the following content:
Parse.Cloud.define('hello', function(req, res) {
res.success('Hi');
});
Now open the server.js file and find the line containing the path to the cloud code file. Change it to point to you main.js file like this:
This could be any arbitrary folder of your choosing.
Now just restart your parse server and call the cloud function:
String result = ParseCloud.callFunction("hello", new HashMap<>());
This is with the Java SDK but should not be much different. The variable result will equal "Hi" if you've used the function from above.

dropwizard get on demand jdbi connection

I have a simple CRUD application with backend code in dropwizard. The entire app just comprises of simple resource classes and crud operations except one case where some business logic is involved.
I am trying to extract this into a service instead of putting it in the resource class itself. But for that my service would need an ondemand jdbi connection to access data and do its thing.
All my connect strings and config values are in YML file. Since this app would be running on different servers with different yml files, I dont want to hardcode the yml file name in order to read it again, to get the connect strings and do it that way.
How do I achieve this?
Can you detect what environment you are on?
If so, can you do something like ${environment}.yml?
There is Configuration project on apache which might help.
Otherwise, is it a case of in dev you want to run
java -jar app.jar server dev.yml
and in prod you want to run java -jar app.jar server prod.yml? I imagine you have separate daemons in each environment. So, those environment's will pick up the right configuration, if you've configured them that way.
Otherwise, if the property names are the same, but their values differ, and you pick up the right yml in the right environment, things should work.
If I haven't addressed your question, can you please elaborate your problem a little more?

Grails 2.5.0: way to fill database automatically

I have a business web application made with Grails 2.5.0.
In this application, I use a GSP form to upload files and to fill a database.
In fact, I upload httpd conf files from a directory and I extract informations from them.
Now, I want to find a solution to do the same automatically. But I didn't find solution.
I tried Spring Batch plugin but it does work with Grails 2.5.0.Other Batch plugin seems too old to work.
Other way, it perhaps to import files at startup but I don't know if you can read files from a directory at startup ( e.g : from /var/myapp/conf ).
If you want to execute something when the application starts add it to BootStrap.groovy

Rabbitmq erlang client build failed due to file paths problems?

I have been able to build rabbitmq server on ubuntu linux. It came already prepackaged and on making, it is able to start as a service. When i got the client source, i failed to make because it appeared like it needed a folder called ./deps/rabbitmq-server. Analysing the code, i find that the author of the client was accessing the same header files as are found in the server, using include_lib("path to rabbit.hrl e.t.c") in his header file called "amqp_client.hrl". I then decided to add rabbitmq_server in the lib dir of erlang so as its paths are automatically added on start up of the vm. But still this didnot help. There is also another folder which the client references called "rabbit_common" for an include folder he assumes would contain all the .hrl files there. Please assist me in building both the client and server on my ubuntu server, for testing.
Also, if anyone has used RabbitMQ server for IMs, please provide some benchmarks and/or your findings on its throughput, speed and number of users. How can it be compared to ejabberd?. How can one create AJAX/Jquery/Javascript clients for Web functionality?
thanks
I hope you had made some progress as far as RabbitMQ and ejabberd are concerned.
Below is a link to an interesting discussion that might be of help.
http://old.nabble.com/AMPQ-vs-XMPP-and-RabbitMQ-vs-ejabberd-td17587109.html

Resources