Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the server-side development process under Linux?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "what is the server-side development process under Linux". In the daily operation, I believe that many people have doubts about what the server-side development process is under Linux. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "what is the server-side development process under Linux". Next, please follow the editor to study!

Familiar with Linux operation

Task management

Sometimes you execute the command to copy a large file on the command line, which is time-consuming and monopolizes the terminal, so you can first use the Ctrl+z command to suspend the current task (job), and then enter the command, and then use the bg command to let the currently suspended task run in the background (background).

Using the jobs command, you can view the program and job-id currently running in the background, and then if you want it to run in the foreground, you can execute fg [% job-id] to restore it to the foreground.

What if you want to kill a task that is currently running in the background? Use kill job-id

Construction of development environment

Our operating system is Red Hat Enterprise Linux 5, the machines are X86 architecture, 64-bit machines. The code files here are all encoded with GBK by default.

Log in to the configuration of the machine, the jumping machine of the group, the configuration of ssh will be broken automatically after not operating for a period of time, and you need to enter the password + token every time you log in. Using the ControlMaster of ssh, you can solve the problem. See my ssh configuration under linux, there are many window managers, you can conduct multiple independent sessions in one window [without opening multiple terminals], and resume the session [even if the network connection is interrupted. Users will not lose control of the command-line session that is already open]. It is recommended that screen's default screen configuration is a bit poor and conflicts with shell shortcuts. After the configuration, the interface display is very powerful. You can refer to my screen configuration corresponding to the screen shortcut key of the above configuration: Ctrl+j,c to create a new session Ctrl+j,d detach.

GNU toolchains are already available in engraved operating systems. Commonly used are: * GNU make: automated tools for compile and build * GNU compiler collection: GCC* GNU binary tools: including linkers (linker), assemblers (assembler), and other tools

Code editor I started using vim, basically did not install any plug-ins, and then into the embrace of emacs, mainly emacs,eshell and gdb together, not only to meet my daily needs, and let me feel much more efficient, and emacs environment installation is relatively simple. But on our company's server, vim is standard and emacs needs to be installed on its own. Get used to emacs, and then switch back to vim, a lot of shortcut keys are forgotten, very painful! Vim beginner materials and some Vim practical tips under the Linux environment shell and vim garbled causes and elimination of garbled problems often beginners are plagued by garbled problems, this article explores the causes of garbled in shell and vim and solutions emacs installation and use, now dig a hole here, later have time to write if you look at the code under Windows Recommend Source Insight, very easy to use, who knows who uses it.

Code version management

Currently, svn commands are used for version management of the code on the through train:

See what changes have been made to the local code svn st-Q

Submit the code svn ci filepath/-m "svn comments"

Check what are the changes between the two versions of svn diff-r r1:r2 svn diff-r r1:r1-- summarize # this command is in summary mode and only shows which file changes, not the specific file content diff

Create a branch svn cp http://destpath/trunk http://destpath/branches/my-branch/-m "create branche for xxx"

Merge the branch code into the trunk svn merge-r 14829:HEAD my/branch http://path/to/trunk the above command indicates that the local my/branch represents 14829 of the svn path to the latest version of the code, merge to the http://path/to/trunk path. If the branch is pulled out normally, the version parameter can not be added. Svn can automatically calculate the starting version number of the branch. When the newcomer merges the code, you must pay attention to it and confirm whether the merged code is OK before submission. If there is anything you don't understand, consult your brother.

Check who changed the svn blame filename at the end of a piece of code.

Update the specified file to a specified version of svn up-r rev file

Undo the local changes in a file svn revert file # this command should be used with caution. After using it, one's own changes will not be found.

Command to resolve conflicts if prompted after svn merger: local add, incoming add upon merge uses the following command to adopt local changes to resolve: svn resolve-- accept working-R [--recursive]

Under Mac, it is recommended to use Meld with graphical interface as the merge tool of svn, which can easily deal with conflicts and reduce the possibility of error code.

Development [teased as writing bug]

Before you develop, it's best to know these things:

Related materials on what Makefile uses to complete automatic compilation can be found in the Makefile series written by Chen Hao and me, and the pdf version organized by enthusiastic netizens can be found online. It will be enough after reading the first four chapters, and the later chapters can be checked again when you are in doubt. You can use the following frequently asked questions to check whether you understand the entire project Makefile how to modify Makefile to compile a version with / without gdb debugging information how to remove / add compiler optimization options, such as-O2 parameter newly added header file (usually .h ending), source file (usually .cpp ending), how to add the corresponding rules in Makefile. The newly added file may eventually be put into static library .an or dynamic library .so, or directly generate executable programs generally do not write makefile directly, but use cmake (cross platform make) to generate makefile, and then build the software in the way of make. Advanced readings: how to debug Makefile variables

What you need to know about static libraries and dynamic libraries are What: what is static libraries and what is dynamic libraries How: how to generate static libraries, dynamic libraries Why: the differences between static libraries and dynamic libraries, when to use static libraries, and when to use dynamic libraries.

All the above questions can be answered in LibraryArchives-StaticAndDynamic,shared libraries.

Reference:

Two problems that rookies may encounter when compiling and linking in C language

A book recommended by Niu Yunfeng for programming

The book recommended by Lao Zhao, a big programmer, is so thick that you can pick and read the chapters you care about.

GNU compilation tool GCC needs to know at least some commonly used option parameters: define the name of the output file to generate information about gdb debugging control the code optimization level only preprocess can help debug some macro definitions / header files contain problems only the compilation process only the link process can get the answer to the above question through the man gcc, you can also google,google the wall can use this ask

What about the error in the execution result of the GNU debugger gdb program? What if it can't be tested alone? What if there is a Core online? Don't worry, GDB will help you. How does a novice survive in gdb? through a small example to get a novice to get started quickly, it is basically enough to use several debugging methods that should be known in GDB. Some of the gdb commands I searched [will be constantly updated, welcome to reply]: check the contents of the pointer array p / x * address@len displays the len elements at the beginning of the address in hexadecimal mode after starting the program through gdb How to debug the child processes from fork: the services on the set follow-fork-mode child through train are basically a multi-process model. First start a daemon parent process, and then fork multiple child processes that execute business logic. If the child process dies, the parent process restarts a child process.

Multithreading support

At present, POSIX Theads is used in the multithreading mechanism on the through train.

For POSIX Theads, you need to know:

What: what is thread,pthread

How: how to use pthread to compile multithreaded programs, how to create / end threads, how to wait for child threads to return (join/detach), how to use mutexes (Mutex) to synchronize, lock, and avoid race conditions?

Why: why use pthread and not others

Answers to all these questions can be found in the pthead tutorial at Lawrence Livermore National Laboratory in the United States.

Find / replace strings / find files / text processing

What if you want to find the definition of a macro / function? grep-r-- include=*. {cpp,h} NGX_HTTP_VAR_INDEXED src/ this command means to look for the string NGX_HTTP_VAR_INDEXED recursively in a file ending with .cpp or .h in the src directory.

What to do if you want to find a file that vaguely remembers its name? find. /-iname "* util.h" this command means to find a file in the current directory based on the name of the file that ignores case. The file name is regular expression * util.h on regular expressions. I only read this deerchao article: regular expressions 30 minutes introduction tutorial another web application regexr is very good, can help us debug regular expressions

For example, the text processing streaming editor sed replaces a string: sed-I's _ for _

Advanced readings:

Linux skills that you should know

28 Unix/Linux command line artifacts

About single Test (unit test)

A single test is very important, it can make you more confident and confident in your code, and can help you find and solve problems earlier. At all stages of development, the later the problem is discovered, the greater the cost of solving the problem. The gtest framework of Google is used in the single test of C++ here, even if you don't know the gtest framework before, you can write a single test by looking at other people's code, but it's best to take a look at the official gtest documentation, to have a comprehensive understanding of gtest, and to expand your mind.

As you write the code, you find that your code is becoming more and more complex and not easy to read. What if the design is chaotic? You can get information by private mail [learning materials] in the background.

Compile (compile), build (build)

The preparation before compilation needs to fix the compilation dependency environment, which is basically enough to install the package that the compilation depends on. You can find the corresponding spec file in the rpm directory, and then use the t-abs command [for debugging spec files locally and automatically deploying the compilation environment] to help us install the packages that are dependent on compilation, that is, the packages specified in the BuildRequire section of the spec file are about rpm and spec files. You can read this article to understand: How to create an RPM package

Compile to find the Makefile of the corresponding project, and then execute the make command, you can compile the construction project due to the flexibility of make itself, and the readability of Makefile is not strong, is to take the file as a unit, the level of abstraction is not enough, Google developed a distributed construction system Bazel, which can liberate programmers from make syntax and file-level construction. Bazel related materials are: introduction to the principle of Google Blaze and the use of Bazel.

At present, we are still using RPM for package management.

The rpm commands you usually need to use are: rpm-qf file-name to see which rpm-qi package-name of a file is in the rpm package to view the information related to the rpm package, such as the packing time Rpm-ql package-name such as svn address to check which files are in the rpm package rpm-qV package-name to verify whether the installed file of the rpm package has been modified, which is very useful when it is suspected that the configuration / script of the rpm package has been modified.

Code review

UI interface: reviewboard, when submitting, use the rbt command: rbt post R1 R2 to submit the diff between R1 and R2 as codereview, you can get a reviewboard address, and then you need to fill in the codereview personnel and related descriptions, etc.

Continuous integration of CISE

CISE provides users with automated environment deployment and testing services, which are different for each company.

Installation package

For the built rpm package, use yum to install it.

Taobao rpm package query UI here you can see the existing versions of each package in the Taobao yum source, and you can see the abs address of the corresponding package.

Install using the following command:

_ _ sudo yum install-b test t-imatch-kgb-updated _ _

The-b parameter is used to specify that the current installation package t-imatch-kgb-updated must be converted to current when it is launched in the test branch or the current branch.

At this point, the study on "what is the server-side development process under Linux" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report