Auto detect internal/external development environment

后端 未结 5 739
清歌不尽
清歌不尽 2021-02-04 14:04

We use the following function to auto detect if we are on a machine internally or on a live server and then choose the appropriate configs for various components:



        
5条回答
  •  忘掉有多难
    2021-02-04 14:32

    Create and later look for a file that only exists on the live server's filesystem.

    Granted, your environments should be as similar as possible; what I'm suggesting is something like this: in directory /var/environment/, have a file named {devel|test|qa|staging|live}, depending on the server you're on - then just check the filename.

    Of course, you need to exclude this file from version control and from whatever build process you may have.

提交回复
热议问题