I'm looking for some suggestions on how I could manage external dependencies when I want to run my Play framework based app locally.
I have a Play based application that connects to a database to look up application data. In order to run this against a specific environment, it is not a problem, but what if say I want to run this locally? With the current setup, if there is no database available, my app would just not start! I mean, without a database running my application also has no meaning as I could not do anything without data!
I'm using MongoDB as my database, so I see the following possibilities to enable running my application locally!
Use in memory mode from MongoDB
Use some sort of docker container to run a MongoDB instance locally
Is there any other possibility that is worth exploring?
Related
I mean, for example, installing a database using a webserver then deploy the database with my application without more configuration, just a portable database, is it possible? Currently my mongo database is installed and dependent of my computer system, I would make it portable, it is possible to build a database upon my webserver, hence make it portable?
Any hint would be great,
thanks
We have a cloud-foundry app that is bound to a Postgresql service. Right now we have to manually connect to the Posgresql database with pgAdmin, and then manually run the queries to create our tables.
Attempted solution:
Do a cloud foundry run-task in which I would install
1) Install psql and connect to the remote database
2) Create the tables
The problem I ran into was that cf run-task has limited permissions to install packages.
What is the best way to automate database table creation for a cloud-foundry application?
Your application will run as a non-root user, so it will not have the ability to install packages, at least in the traditional way. If you want to install a package, you can use the Apt Buildpack to install it. This will install the package, but into a location that does not require root access. It then adjusts your environment variables so that binaries & libraries can be found properly.
Also keep in mind that tasks are associated with an application (they both use the same droplet), so to make this work you'd need to do one of two things:
1.) Use multi-buildpacks to run the Apt buildpack plus your standard buildpack. This will produce a droplet that has both your required packages and your app bits. Then you can start your app and kick of tasks to set up the DB.
2.) Use two separate apps. One for your actual app and one for your code that seeds the database.
Either one should work though. Both are valid ways to seed your database. The other option, which is what I typically done, is to use some sort of tool to do this. Some frameworks like Rails, have this built-in. If your framework does not, you could bring your own tool, like Flyway. These tools often also help with the evolution of your DB schema, which can be useful too.
I implemented a server application with Play Framework.
I built native packages for different Operating Systems (Linux, Windows, Mac OS X) with SBT Native Packager.
This application requires a NoSQL Database. In particular, I am using MongoDB. Is there a way to embed MongoDB binary/package in my native package? Is this the best practice? Or do you suggest to install MongoDB and my Play application with two different packages?
If it is not possible / recommended to embed MongoDB in a package, do you suggest another DBMS (for instance Nitrite Database)? Thanks
This is not really best practise. Play has H2 in-memory DB embedded but this is only intended for development (because it is quicker than something that reads/writes to disk as well).
You really want to have your Mongo (or whatever other data store you decide to use) instance running in a different process, and packaged, deployed, stopped, started separately from your Play application.
You could probably figure out how to package it with your Play application and then have some script run during app startup to setup the database and load any existing data in -dbpath ie. whenever you redeploy/restart your application. But then you would have to stop/redeploy your Mongo binaries each time you redeploy a code change. You may update your application several times over a year but you are unlikely going to want to update your Mongo binaries as often. I could go on, but don't do it. It is best practise to manage your data stores separately from your applications.
I am trying to run a very simple REST API backend on EC2 for an Android App I am making for a school project. In a previous project, I used a NodeJS library, expressJS, to quickly create a backend that executes SQL updates/queries, and in the current project, I am using Java and a Java library called Spark to do the same thing (SQL queries/updates). I start a refreshed backend with
git pull; mvn clean install; mvn exec:java;
because I am using Maven. Anyway for both the previous ExpressJS and the current Spark backend, I can talk to the server for an hour or two perhaps, then I have to restart it. Why doesn't it just keep running? Is there some problem with my connection to the database leaking memory? You can check out the project here. I tried using nohup, but that didn't do it either; it still crashed after a few hours. It's not getting too many requests. Any other comments on improvements to my process or backend are welcome as well.
Thanks!
I did not close my database connections. The server kept open the connection until crashing.
When creating a Meteor app., Mongo is installed by default and runs automatically when I run my app. In the past, with other non-Meteor apps, I have always tried to place my app code files and database on separate servers to ensure that I can scale them independently. It feels as though this default Mongo install is a convenient way simply for Meteor to use a database out-of-the box, just to get you going. Thinking ahead, I want my app to scale, so should I start thinking about using a Mongo instance on separate server and, if so, what process do I go through to detach this default Mongo instance from my Meteor app?
The instance of mongodb that comes with meteor is only for use when developing your app. In a production environment, you should either install your own mongo instance or use a service.
I strongly recommend using compose.io in production. We've had a really good experience with them and the most basic deployment comes with access to the oplog which is critical for scaling your app.
Either way, in production you will provide two URLs to your app via environment variables:
MONGO_URL
MONGO_OPLOG_URL (this is optional but strongly recommended)
If you go with compose, here is the guide for integrating with meteor.