📜 ⬆️ ⬇️

We roll into battle

To battle! The implementation of the final web product is not the most pleasant procedure for the creator and is often accompanied by terrible stress. The developer's dislike for releases is associated not only with feelings of responsibility and fear of exploiting the new version, but also with feelings of uncertainty: what will happen after we introduce ourselves?

Applications can be developed by a large team of programmers, quality engineers, graphical interfaces, but at the end of the project path, the last of the Mohicans takes responsibility. The lack of theoretical knowledge makes our hero nervous, because the experience gained through trial and error, under the hour is not enough for a systematically successful implementation. To figure out how to roll out web projects into battle, let's start with the basics.

General Staff Plan

development process
')
After receiving the requirements, specifications, various recommendations and instructions, the developer allocates space for his maneuvers in the source code repository. This area can be a personal SVN branch, a new module in CVS or a folder on the file system.

It makes no sense to talk in detail about the subsequent cycles of “Develop - Test - Deploy”: it is written about them and so many useful things. I will note only important observations:The final results of the development are recorded in the release candidate (the branches merge, a tag is created, etc.) and transferred to acceptance testing. A release candidate is an end-to-end monolithic product that cannot be modified. If you need to correct mistakes, refine the functionality, you need to start from the beginning and make a new candidate.

Hard to learn

It is worth noting that many managers conduct acceptance testing in the development environment, which is fundamentally wrong. It is clear that to make a separate candidate for nano-bugs is very lazy (and wasteful). But the procedure of introduction to the test platform, once worked out, will significantly save the developer time and nerves. Moreover, no one bothers to put small fixes into groups and fix them in one version of the product.

The main hints of acceptance testing:The transition from the candidate to the release may take a certain number of iterations "Candidate - Testing - Change". During the cycle, there will be new bugs, changing requirements and changes. Ultimately, you have to break the vicious circle and make a release. And it is extremely rare for a pre-release test report to be 100% complete (developers in such cases are otmazyvatsya prefix beta ).
I once ruled the development of a portal about advertising. The team then had to roll out ~ 20 candidates before the release was introduced. The release was implemented from the 10th time. The final test report was successful at ~ 70%. Not the most successful project in my life.

To arms

The order of introduction of the release should be as follows:
  1. We introduce new versions of platform components . We update libraries, services, etc., while keeping the tool for rolling back to the old versions.
  2. We implement a DB and file storage . If the previous version of the application is working in combat, you need to prepare in advance the old release to support the new storage structure. The story is this:
    • We add to the previous release support for a new storage scheme
    • we introduce the changed previous release
    • we introduce a new storage structure and migrate data (the previous release should work in the old logic with the new storage)
    • introducing a new release
  3. We implement the application .
  4. Testing the application .
  5. Roll back (if necessary).
In the case of a fackup, we roll back to the previous version in the reverse order:
  1. Roll back the application .
  2. Roll back the database and file storage (if necessary).
  3. Roll back platform components (if necessary).

Application to battle

First, the application must be designed in such a way that its folder structure is separated from the file storage.
Right
 / var / www / myproject /
	 / etc /
	 / lib /
	 / classes /
	 / images /
	 / templates /
	 index.php
 / var / www / userdata /
	 / images /
	 / video /
Not properly
 / var / www / myproject /
	 / etc /
	 / lib /
	 / classes /
	 / images /
	 / templates /
	 / userdata /
		 / images /
		 / video /
	 index.php
Secondly, it is necessary to control versions of third-party libraries. To be sure that the supported version of the Zend Framework library is used in combat, you must either include the library in the folder structure of the application (and keep it in svn ), or present the release as a package (for example, deb ) with which to check dependencies.

Thirdly, many developers embed an application into battle with an update from the source code repository ( svn up ). This approach can only be compared with rm –rf / . The release must be completely removed from the repository and placed in a separate place from the previous release.
Releases are placed in separate folders on the battle platform.
 user @ stable: ~ / apps / myproject $ ls -la
 drwxr-xr-x 12 user www-data 4096 Oct 29 11:38.
 drwxr-xr-x 5 user www-data 4096 May 13 23:22 ..
 drwxr-xr-x 8 user www-data 4096 Oct 22 17:11 rel_0.5.1
 drwxr-xr-x 8 user www-data 4096 Oct 27 13:17 rel_0.5.1.1
 drwxr-xr-x 8 user www-data 4096 Oct 28 02:07 rel_0.5.1.2
 drwxr-xr-x 8 user www-data 4096 Oct 29 11:38 rel_0.5.2
 user @ stable: ~ / apps / myproject $ svn co svn + ssh: //user@svn.myproject.ru/myproject/tags/rel_0.5.2.1
 ...
 user @ stable: ~ / apps / myproject $ ls -la
 drwxr-xr-x 12 user www-data 4096 Oct 29 11:38.
 drwxr-xr-x 5 user www-data 4096 May 13 23:22 ..
 drwxr-xr-x 8 user www-data 4096 Oct 22 17:11 rel_0.5.1
 drwxr-xr-x 8 user www-data 4096 Oct 27 13:17 rel_0.5.1.1
 drwxr-xr-x 8 user www-data 4096 Oct 28 02:07 rel_0.5.1.2
 drwxr-xr-x 8 user www-data 4096 Oct 29 11:38 rel_0.5.2
 drwxr-xr-x 8 user www-data 4096 Oct 29 12:31 rel_0.5.2.1
After extracting the source code, the project is installed (configurable configs, permissions, starting data) and tested next to a working release, for which a separate virtual web server host can be used (for example, www-test.myproject.ru ). After running the test plan, the previous release is replaced by a new one. The following options for replacing releases are known: changing the symbolic link, mount_null , changing the web server config , followed by graceful restart .
With a symbolic link we switch the project from one release to another.
In the same way, you can roll back to the previous version.
 user @ stable: ~ / httpdocs / $ ls –la
 drwxr-xr-x 3 user www-data 4096 Oct 29 11:40.
 drwxr-xr-x 9 user www-data 4096 Oct 28 21:25 ..
 lrwxrwxrwx 1 user www-data 27 Oct 29 11:40 pro -> ../apps/myproject/rel_0.5.2
 user @ stable: ~ / httpdocs / $ rm pro && ln –s ../apps/myproject/rel_0.5.2.1 pro
 user @ stable: ~ / httpdocs / $ ls –la
 drwxr-xr-x 3 user www-data 4096 Oct 29 11:40.
 drwxr-xr-x 9 user www-data 4096 Oct 28 21:25 ..
 lrwxrwxrwx 1 user www-data 27 Oct 30 17:12 pro -> ../apps/myproject/rel_0.5.2.1
If the application is distributed:The more servers are involved and the more complex the structure of the application, the greater the need for automation tools and implementation control. However, do not forget the favorite rule of futurologists: do not trust the robots - they were created by people who are prone to make mistakes.
PS If you have enough strength to finish the story, wait for the second part about the virtues of LiquiBase , the rsync pitfalls and the migration of file storages.
PPS In the course of correspondence with one of the habrayuser it was formulated: the main thing in this informational appeal is not to impose one's recommendations, but the fact that I make a person think about the problems that may arise in his particular situation. General recommendations on * ^ & no one needs. In the end, everyone makes their own way. And it is right. Because every project is unique.

Source: https://habr.com/ru/post/43643/


All Articles