How to deploy changes to production without downtime (generic hosting)? - strapi

What is the recommended way to deploy changes (for example change in some Content Type model) from development to production without downtime?
I’m using this setup.
I have development instance with development postgres database.
On production I have 3 strapi instances (serving both api & admin, using the same production postgres database) and those instances are behind loadbalancer.
Lets say that I have Content Type named: Article (both on development and deployed on production).
Lets assume that I want to change that content type for example I want to add some fields and remove some fields in Article content type.
How to deploy changes to production without downtime?
I’ve done some tests and when I for example update Strapi Production Instance #1 to pull new code for updated models, strapi will update database of course. And from that time Strapi Production Instance #2 and #3 have problems serving Admin panel for example (javascript errors because database was changes but JS model files are not updated).
After I updated code on instance #2 and #3 everything works as expected.
But doing something like this on “working product” will be visible as downtime.
How to properly handle this situation? Thanks for help!

Could PM2 solve this problem? Strapi mentiones this in their documentation
PM2 Runtime allows you to keep your Strapi project alive and to reload it without downtime.
Strapi Docs v4

Related

Why do I lose contents of my database after a heroku dyno restart?

Anytime my app goes to sleep and comes back on, I lose data in my database
And I'm not storing any media, it's just form data (texts)... I built the app on strapi and I've followed all their guidelines but it keeps happening. I'd be happy if anyone can help
Local data (files, db) is cleared after a Dyno restart because the Heroku File System is ephemeral. A Dyno is restarted (at least) every 24hrs.
In your case Strapi uses SQLite where data is saved in a local file.
Strapi suggests to configure Postgres on Heroku, alternatively you can use an external DB storage service.
First of all:
As you create content types with strapi it generates the code (= new files) for the according controllers/routes/services
Heroku does not persist data after a restart
After a restart strapi checks which content types exist in the code and deletes the tables of nonexisting types from the database.
Therefore, on Heroku you have to set up all your content types locally and connect to an external db (e.g. Heroku Postgres) but never strapi's default textfile based db.
Then push the generated files and finally deploy.
Thus, on Heroku you should always run in production mode. This way the option to alter content types is completely blocked and you will not run into the issue of data loss after a restart.

Data does not persist when dyno is restarted in Heroku?

I have deployed Strapi headless CMS on Heroku free tier and tried to use it both with MongoDB and Postgres databases, whenever I restart the dyno e.g. during deployment - all the data created thus far is not persisted?
I tried rebuilding Strapi locally and I cannot reproduce the behaviour.
I am using free tier for hosting of Strapi as well as free tier of Heroku Postgres.
Most likely you created your project with --quickstart which is not Postgres, it is SQLite. Can you please check your config/environments/*/database.json files and ensure you have PostgreSQL setup?
All model configs are stored in files meaning you will not be able to create, edit, or delete new models, fields, components while using Heroku. All data (content) is saved to the database.
https://strapi.io/documentation/3.0.0-beta.x/guides/deployment.html#heroku

Bluemix and CMS (Joomla) and CF Push

I have installed a Joomla site with CF on bluemix.
As you know Joomla as other CMS allows to install components for adding functionalities.
This uploads the php code needed for the component and add additional tables/entries in the Database.
My issue is that when I CF PUSH, the new component script is removed from the joomla folders on bluemix, and the database still contains component's tables/entries.
I guess this is the situation for all CMS (Drupal, Wordpress, Joomla, Vbulletin, etc..).
How could I get a kind of CF PULL (?) to keep the modified CMS code including the new component locally on the computer side ?
So when i will redo the CF PUSH the installed component will not be erased.
Thank you in advance for your support,
Best regards
Yves
There is no cf pull command in Cloud Foundry. The closest you would have is the cf files app-name command that you can navigate the directory structure of your cloud application and get specific files as needed, but this would be really tedious if you have multiple files to copy to your local computer.
It looks like Joomla fits better with the IBM Containers service in Bluemix. With the IBM Containers you can have an Docker image from Joomla (https://hub.docker.com/_/joomla/) and use persistent Volumes to save your added functionality. You can also use any Bluemix services (like a database) with IBM Containers.
The article below provides more details and step by step instructions to create an IBM Container for Wordpress. You can easily modify it for Joomla:
http://blog.ibmjstart.net/2015/05/22/wordpress-on-bluemix-containers/
When you push an application on a runtime, php Java or whatever, it will restage all the application sources, included what has been configured and modified before through the cms interface, leaving the db databases untouched. And it is for joomla, but also for drupal or WP or any other cms. By this way to achieve what you wish you have 3 options:
- push exactly the filesystem structure you need on Bluemix, including the configuration files and modules to use on it
- use (as suggested above) a container instead of a runtime: anyway also with a container you have to install your cms on an external docker volume, otherwise the cms will be reset every time you restart the container
- use a Bluemix VM

Development versus Production in Parse.com

I want to understand how people are handing an update to a production app on the Parse.com platform. Here is the scenario that I am not sure about.
Create an called myApp_DEV. The app contains a database as well as associated cloud code.
Once testing is complete and ready for go-live I will clone this app into myApp_PRD (Production version). Cloning it will copy all the database as well as the cloud code.
So far so good.
Now 3 months down the line I want have added some functionality which includes adding some cloud code functions as well as adding some new columns to the tables in the db.
How do I update myApp_PRD with these new database structure. If i try to clone it from my DEV app it tells me the app all ready exists.
If I clone a new app (say myApp_PRD2) from DEV then all the data will be lost since the customer is all ready live.
Any ideas on how to handle this scenario?
Cloud code supports deploying to production and development environments.
You'll first need to link your production app to your existing cloud code. this can be done in the command line:
parse add production
When you're ready to release, it's a simple matter of:
parse deploy production
See the Parse Documentation for all the details.
As for the schema changes, I guess we just have to manually add all the new columns.

Umbraco 7 fields show locally, but not at remote server?

Does anyone know about this problem: Any new fields I add work fine in the local back office, but when I use Webmatrix to publish to the server (discountASP.net) fields don't show up. I did a view source in the browser and they're just not there!
For example, #Umbraco.Field("comments")
Thanks!
Daniel
If you add new field, they are only added in the database. That means you would need to update the database on the production website. Webmatrix doesn't do this for you (by default).
There are a few ways to handle this scenario:
copy your database to the production server (i would advice against this, because you might overwrite content and media changes on the production server)
create the fields manually on the production server (easy solution)
use a commercial package like courrier (personally i believe it's a good solution, only if you have a content staging workflow)
use a free package like usync (http://our.umbraco.org/projects/developer-tools/usync)

Resources