config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								/ *  
						 
					
						
							
								
									
										
										
										
											2019-08-13 12:25:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								 *  MinIO  Cloud  Storage ,  ( C )  2015 - 2019  MinIO ,  Inc . 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Licensed  under  the  Apache  License ,  Version  2.0  ( the  "License" ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  you  may  not  use  this  file  except  in  compliance  with  the  License . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  You  may  obtain  a  copy  of  the  License  at 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *      http : //www.apache.org/licenses/LICENSE-2.0
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  Unless  required  by  applicable  law  or  agreed  to  in  writing ,  software 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  distributed  under  the  License  is  distributed  on  an  "AS IS"  BASIS , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  WITHOUT  WARRANTIES  OR  CONDITIONS  OF  ANY  KIND ,  either  express  or  implied . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  See  the  License  for  the  specific  language  governing  permissions  and 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 *  limitations  under  the  License . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								 * / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-19 07:23:42 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								package  cmd  
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								import  (  
						 
					
						
							
								
									
										
										
										
											2020-05-23 12:59:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"bufio" 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-06 06:04:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"context" 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-14 09:38:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"errors" 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-09 10:04:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"fmt" 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-23 12:59:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"io" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"log" 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-19 07:19:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"net" 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-07 11:35:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"os" 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-13 07:33:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"os/signal" 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-19 08:51:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"strings" 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-13 07:33:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"syscall" 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-23 03:16:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"time" 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"github.com/minio/cli" 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-05 01:35:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/minio/minio/cmd/config" 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-22 10:23:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									xhttp  "github.com/minio/minio/cmd/http" 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-06 06:04:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/minio/minio/cmd/logger" 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 13:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/minio/minio/pkg/auth" 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-01 03:30:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/minio/minio/pkg/certs" 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-05 01:35:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/minio/minio/pkg/color" 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									"github.com/minio/minio/pkg/env" 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-09 02:28:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									"github.com/minio/minio/pkg/retry" 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-06-10 22:57:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// ServerFlags - server command specific flags
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var  ServerFlags  =  [ ] cli . Flag {  
						 
					
						
							
								
									
										
										
										
											2016-09-02 06:12:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									cli . StringFlag { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Name :   "address" , 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-17 23:46:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Value :  ":"  +  GlobalMinioDefaultPort , 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-21 09:35:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										Usage :  "bind to a specific ADDRESS:PORT, ADDRESS can be an IP or hostname" , 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-02 06:12:49 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								var  serverCmd  =  cli . Command {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Name :    "server" , 
							 
						 
					
						
							
								
									
										
										
										
											2018-11-21 09:35:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Usage :   "start object storage server" , 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-10 22:57:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									Flags :   append ( ServerFlags ,  GlobalFlags ... ) , 
							 
						 
					
						
							
								
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											 
										 
										
											2016-04-02 10:19:44 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									Action :  serverMain , 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									CustomHelpTemplate :  ` NAME : 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-17 03:21:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  { { . HelpName } }  -  { { . Usage } } 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								USAGE :  
						 
					
						
							
								
									
										
										
										
											2018-02-16 09:45:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  { { . HelpName } }  { { if  . VisibleFlags } } [ FLAGS ]  { { end } } DIR1  [ DIR2 . . ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { { . HelpName } }  { { if  . VisibleFlags } } [ FLAGS ]  { { end } } DIR { 1. . .64 } 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 12:30:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  { { . HelpName } }  { { if  . VisibleFlags } } [ FLAGS ]  { { end } } DIR { 1. . .64 }  DIR { 65. . .128 } 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-16 09:45:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								DIR :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  DIR  points  to  a  directory  on  a  filesystem .  When  you  want  to  combine 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  multiple  drives  into  a  single  large  system ,  pass  one  directory  per 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  filesystem  separated  by  space .  You  may  also  use  a  ' ... '  convention 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  to  abbreviate  the  directory  arguments .  Remote  directories  in  a 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  distributed  setup  are  encoded  as  HTTP ( s )  URIs . 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-16 09:45:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{ { if  . VisibleFlags } }  
						 
					
						
							
								
									
										
										
										
											2016-08-29 11:04:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								FLAGS :  
						 
					
						
							
								
									
										
										
										
											2017-02-15 18:25:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  { { range  . VisibleFlags } } { { . } } 
							 
						 
					
						
							
								
									
										
										
										
											2017-02-16 09:45:08 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  { { end } } { { end } } 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								EXAMPLES :  
						 
					
						
							
								
									
										
										
										
											2016-11-10 15:37:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  1.  Start  minio  server  on  "/home/shared"  directory . 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-15 16:32:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . HelpName } }  / home / shared 
							 
						 
					
						
							
								
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											 
										 
										
											2016-04-02 10:19:44 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-22 14:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  2.  Start  single  node  server  with  64  local  drives  "/mnt/data1"  to  "/mnt/data64" . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . HelpName } }  / mnt / data { 1. . .64 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  3.  Start  distributed  minio  server  on  an  32  node  setup  with  32  drives  each ,  run  following  command  on  all  the  nodes 
							 
						 
					
						
							
								
									
										
										
										
											2019-05-15 16:32:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . EnvVarSetCommand } }  MINIO_ACCESS_KEY { { . AssignmentOperator } } minio 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . EnvVarSetCommand } }  MINIO_SECRET_KEY { { . AssignmentOperator } } miniostorage 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 12:07:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . HelpName } }  http : //node{1...32}.example.com/mnt/export{1...32}
 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-19 08:51:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-22 14:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  4.  Start  distributed  minio  server  in  an  expanded  setup ,  run  the  following  command  on  all  the  nodes 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 12:30:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . EnvVarSetCommand } }  MINIO_ACCESS_KEY { { . AssignmentOperator } } minio 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . EnvVarSetCommand } }  MINIO_SECRET_KEY { { . AssignmentOperator } } miniostorage 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-27 12:07:39 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								     { { . Prompt } }  { { . HelpName } }  http : //node{1...16}.example.com/mnt/export{1...32} \
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            http : //node{17...64}.example.com/mnt/export{1...64}
 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								` ,  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-07 09:03:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  serverCmdArgs ( ctx  * cli . Context )  [ ] string  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									v  :=  env . Get ( config . EnvArgs ,  "" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  v  ==  ""  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Fall back to older ENV MINIO_ENDPOINTS
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										v  =  env . Get ( config . EnvEndpoints ,  "" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  v  ==  ""  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  ctx . Args ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  strings . Fields ( v ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-19 08:51:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  serverHandleCmdArgs ( ctx  * cli . Context )  {  
						 
					
						
							
								
									
										
										
										
											2017-06-10 10:50:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Handle common command args.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									handleCommonCmdArgs ( ctx ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-29 23:55:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:08:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . FatalIf ( CheckLocalServerAddr ( globalCLIContext . Addr ) ,  "Unable to validate passed arguments" ) 
							 
						 
					
						
							
								
									
										
										
											
												config: Migrate to the new version. Remove backend details.
Migrate to new config format v4.
```
{
	"version": "4",
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"console": {
			"enable": true,
			"level": "fatal"
		},
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		}
	}
}
```
This patch also updates [minio cli spec](./minio.md)
											 
										 
										
											2016-04-02 10:19:44 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-01-12 05:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									var  err  error 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-07 09:03:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									var  setupType  SetupType 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Check and load TLS certificates.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalPublicCerts ,  globalTLSCerts ,  globalIsSSL ,  err  =  getTLSConfig ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									logger . FatalIf ( err ,  "Unable to load the TLS configuration" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Check and load Root CAs.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-11 23:29:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalRootCAs ,  err  =  certs . GetRootCAs ( globalCertsCADir . Get ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-07 09:03:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . FatalIf ( err ,  "Failed to read root CAs (%v)" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-14 00:46:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Add the global public crts as part of global root CAs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  _ ,  publicCrt  :=  range  globalPublicCerts  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalRootCAs . AddCert ( publicCrt ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-07 09:03:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Register root CAs for remote ENVs
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									env . RegisterGlobalCAs ( globalRootCAs ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-08-16 06:10:50 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-27 03:42:10 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalMinioAddr  =  globalCLIContext . Addr 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalMinioHost ,  globalMinioPort  =  mustSplitHostPort ( globalMinioAddr ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-07 09:03:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalEndpoints ,  setupType ,  err  =  createServerEndpoints ( globalCLIContext . Addr ,  serverCmdArgs ( ctx ) ... ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-09 10:04:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . FatalIf ( err ,  "Invalid command line arguments" ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-02-16 09:45:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-09 10:04:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// On macOS, if a process already listens on LOCALIPADDR:PORT, net.Listen() falls back
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// to IPv6 address ie minio will start listening on IPv6 address whereas another
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// (non-)minio process is listening on IPv4 of given port.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-01-04 09:43:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// To avoid this error situation we check for port availability.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-25 06:02:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . FatalIf ( checkPortAvailability ( globalMinioHost ,  globalMinioPort ) ,  "Unable to start the server" ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-31 10:22:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalIsErasure  =  ( setupType  ==  ErasureSetupType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalIsDistErasure  =  ( setupType  ==  DistErasureSetupType ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  globalIsDistErasure  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalIsErasure  =  true 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-23 16:32:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  serverHandleEnvVars ( )  {  
						 
					
						
							
								
									
										
										
										
											2017-06-10 10:50:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Handle common environment variables.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									handleCommonEnvVars ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  newAllSubsystems ( )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create new notification system and initialize notification targets
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalNotificationSys  =  NewNotificationSys ( globalEndpoints ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-20 04:53:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Create new bucket metadata system.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalBucketMetadataSys  =  NewBucketMetadataSys ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 14:39:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Create a new config system.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalConfigSys  =  NewConfigSys ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create new IAM system.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalIAMSys  =  NewIAMSys ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Create new policy system.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalPolicySys  =  NewPolicySys ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create new lifecycle system.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalLifecycleSys  =  NewLifecycleSys ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-05 17:42:34 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create new bucket encryption subsystem
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalBucketSSEConfigSys  =  NewBucketSSEConfigSys ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 00:42:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-09 04:44:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Create new bucket object lock subsystem
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalBucketObjectLockSys  =  NewBucketObjectLockSys ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 00:42:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Create new bucket quota subsystem
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalBucketQuotaSys  =  NewBucketQuotaSys ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create new bucket versioning subsystem
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalBucketVersioningSys  =  NewBucketVersioningSys ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-22 08:49:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create new bucket replication subsytem
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 10:55:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalBucketTargetSys  =  NewBucketTargetSys ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  initSafeMode ( ctx  context . Context ,  newObject  ObjectLayer )  ( err  error )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Create cancel context to control 'newRetryTimer' go routine.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									retryCtx ,  cancel  :=  context . WithCancel ( ctx ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Indicate to our routine to exit cleanly upon return.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									defer  cancel ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-20 09:42:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Make sure to hold lock for entire migration to avoid
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// such that only one server should migrate the entire config
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// at a given time, this big transaction lock ensures this
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// appropriately. This is also true for rotation of encrypted
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// content.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									txnLk  :=  newObject . NewNSLock ( retryCtx ,  minioMetaBucket ,  minioConfigPrefix + "/transaction.lock" ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									defer  func ( txnLk  RWLocker )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										txnLk . Unlock ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-20 09:42:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-14 09:38:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											var  cerr  config . Err 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// For any config error, we don't need to drop into safe-mode
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// instead its a user error and should be fixed by user.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-14 09:38:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  errors . As ( err ,  & cerr )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-12 04:01:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 07:32:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Prints the formatted startup message in safe mode operation.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Drops-into safe mode where users need to now manually recover
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// the server.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											printStartupSafeModeMessage ( getAPIEndpoints ( ) ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Initialization returned error reaching safe mode and
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// not proceeding waiting for admin action.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											handleSignals ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ( txnLk ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 14:39:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-30 04:07:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Enable healing to heal drives if possible
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  globalIsErasure  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-08 10:43:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										initAutoHeal ( ctx ,  newObject ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-30 04:07:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 02:29:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// allocate dynamic timeout once before the loop
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									configLockTimeout  :=  newDynamicTimeout ( 3 * time . Second ,  5 * time . Second ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-15 09:17:14 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// ****  WARNING ****
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Migrating to encrypted backend should happen before initialization of any
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// sub-systems, make sure that we do not move the above codeblock elsewhere.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-02 09:07:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Initializing sub-systems needs a retry mechanism for
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// the following reasons:
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//  - Read quorum is lost just after the initialization
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//    of the object layer.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//  - Write quorum not met when upgrading configuration
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//    version is needed, migration is needed etc.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									rquorum  :=  InsufficientReadQuorum { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									wquorum  :=  InsufficientWriteQuorum { } 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-09 02:28:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									for  range  retry . NewTimer ( retryCtx )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// let one of the server acquire the lock, if not let them timeout.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// which shall be retried again by this loop.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-18 02:29:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  err  =  txnLk . GetLock ( configLockTimeout ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. trying to acquire lock" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-08 07:12:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// These messages only meant primarily for distributed setup, so only log during distributed setup.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  globalIsDistErasure  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-08 07:12:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. lock acquired" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Migrate all backend configs to encrypted backend configs, optionally
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// handles rotating keys for encryption, if there is any retriable failure
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// that shall be retried if there is an error.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-25 18:29:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  err  =  handleEncryptedConfigBackend ( newObject ) ;  err  ==  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											// Upon success migrating the config, initialize all sub-systems
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// if all sub-systems initialized successfully return right away
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  err  =  initAllSubsystems ( retryCtx ,  newObject ) ;  err  ==  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												// All successful return.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  globalIsDistErasure  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-08 07:12:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													// These messages only meant primarily for distributed setup, so only log during distributed setup.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													logger . Info ( "All MinIO sub-systems initialized successfully" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-02 09:07:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// One of these retriable errors shall be retried.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  errors . Is ( err ,  errDiskNotFound )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											errors . Is ( err ,  errConfigNotFound )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											errors . Is ( err ,  context . Canceled )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											errors . Is ( err ,  context . DeadlineExceeded )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											errors . As ( err ,  & rquorum )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											errors . As ( err ,  & wquorum )  || 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											isErrBucketNotFound ( err )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											logger . Info ( "Waiting for all MinIO sub-systems to be initialized.. possible cause (%v)" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											txnLk . Unlock ( )  // Unlock the transaction lock and allow other nodes to acquire the lock if possible.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											continue 
							 
						 
					
						
							
								
									
										
										
										
											2020-02-02 09:07:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Any other unhandled return right here.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  fmt . Errorf ( "Unable to initialize sub-systems: %w" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Return an error when retry is canceled or deadlined
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  =  retryCtx . Err ( ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  fmt . Errorf ( "Unable to initialize sub-systems: %w" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 14:39:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Retry was canceled successfully.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return  errors . New ( "Initializing sub-systems stopped gracefully" ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  initAllSubsystems ( ctx  context . Context ,  newObject  ObjectLayer )  ( err  error )  {  
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// %w is used by all error returns here to make sure
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// we wrap the underlying error, make sure when you
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// are modifying this code that you do so, if and when
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// you want to add extra context to your error. This
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// ensures top level retry works accordingly.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									var  buckets  [ ] BucketInfo 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  globalIsDistErasure  ||  globalIsErasure  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// List buckets to heal, and be re-used for loading configs.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										buckets ,  err  =  newObject . ListBucketsHeal ( ctx ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  fmt . Errorf ( "Unable to list buckets to heal: %w" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Attempt a heal if possible and re-use the bucket names
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// to reload their config.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										wquorum  :=  & InsufficientWriteQuorum { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										rquorum  :=  & InsufficientReadQuorum { } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  _ ,  bucket  :=  range  buckets  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  err  =  newObject . MakeBucketWithLocation ( ctx ,  bucket . Name ,  BucketOptions { } ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
												if  errors . As ( err ,  & wquorum )  ||  errors . As ( err ,  & rquorum )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													// Return the error upwards for the caller to retry.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													return  fmt . Errorf ( "Unable to heal bucket: %w" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if  _ ,  ok  :=  err . ( BucketExists ) ;  ! ok  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
													// ignore any other error and log for investigation.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													logger . LogIf ( ctx ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
													continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												// Bucket already exists, nothing that needs to be done.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										buckets ,  err  =  newObject . ListBuckets ( ctx ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-07 05:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											return  fmt . Errorf ( "Unable to list buckets: %w" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Initialize config system.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  err  =  globalConfigSys . Init ( newObject ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-12 04:01:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  fmt . Errorf ( "Unable to initialize config system: %w" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 11:04:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Populate existing buckets to the etcd backend
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  globalDNSConfig  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// Background this operation.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										go  initFederatorBackend ( buckets ,  newObject ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 14:39:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-20 04:53:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Initialize bucket metadata sub-system.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  :=  globalBucketMetadataSys . Init ( ctx ,  buckets ,  newObject ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-20 04:53:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  fmt . Errorf ( "Unable to initialize bucket metadata sub-system: %w" ,  err ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 14:39:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Initialize notification system.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-21 01:38:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  =  globalNotificationSys . Init ( ctx ,  buckets ,  newObject ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-12 04:01:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  fmt . Errorf ( "Unable to initialize notification system: %w" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-05 00:42:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 10:55:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Initialize bucket targets sub-system.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-08-21 01:38:53 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  =  globalBucketTargetSys . Init ( ctx ,  buckets ,  newObject ) ;  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 10:55:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  fmt . Errorf ( "Unable to initialize bucket target sub-system: %w" ,  err ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-22 08:49:56 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-31 10:55:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  nil 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-31 14:39:09 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-23 03:16:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  startBackgroundOps ( ctx  context . Context ,  objAPI  ObjectLayer )  {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Make sure only 1 crawler is running on the cluster.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									locker  :=  objAPI . NewNSLock ( ctx ,  minioMetaBucket ,  "leader" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									for  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										err  :=  locker . GetLock ( leaderLockTimeout ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-11 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											time . Sleep ( leaderLockTimeoutSleepInterval ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-23 03:16:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											continue 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										break 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										// No unlock for "leader" lock.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 01:28:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									initDataCrawler ( ctx ,  objAPI ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-23 03:16:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								// serverMain handler called for 'minio server' command.
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								func  serverMain ( ctx  * cli . Context )  {  
						 
					
						
							
								
									
										
										
										
											2020-01-22 07:49:25 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									setDefaultProfilerRates ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 12:30:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Initialize globalConsoleSys system
 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-10 00:30:02 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalConsoleSys  =  NewConsoleLogger ( GlobalContext ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 12:30:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-04-20 01:26:44 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									signal . Notify ( globalOSSignalCh ,  os . Interrupt ,  syscall . SIGTERM ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-11-03 02:53:45 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Handle all server command args.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									serverHandleCmdArgs ( ctx ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-05 01:30:59 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Handle all server environment vars.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									serverHandleEnvVars ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-17 12:30:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Set node name, only set for distributed setup.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalConsoleSys . SetNodeName ( globalEndpoints ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 07:32:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Initialize all help
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									initHelp ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									var  err  error 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-04 02:53:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalProxyEndpoints ,  err  =  GetProxyEndpoints ( globalEndpoints ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-03 01:56:22 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . FatalIf ( err ,  "Invalid command line arguments" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-27 21:25:05 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalMinioEndpoint  =  func ( )  string  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										host  :=  globalMinioHost 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  host  ==  ""  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											host  =  sortIPs ( localIP4 . ToSlice ( ) ) [ 0 ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  fmt . Sprintf ( "%s://%s" ,  getURLScheme ( globalIsSSL ) ,  net . JoinHostPort ( host ,  globalMinioPort ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-12-04 14:47:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Is distributed setup, error out if no certificates are found for HTTPS endpoints.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  globalIsDistErasure  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-20 09:42:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  globalEndpoints . HTTPS ( )  &&  ! globalIsSSL  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-05 01:35:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											logger . Fatal ( config . ErrNoCertsAndHTTPSEndpoints ( nil ) ,  "Unable to start the server" ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-10 10:10:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-20 09:42:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  ! globalEndpoints . HTTPS ( )  &&  globalIsSSL  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-05 01:35:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											logger . Fatal ( config . ErrCertsAndHTTPEndpoints ( nil ) ,  "Unable to start the server" ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-10 10:10:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2017-12-04 14:47:12 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-12-19 08:08:11 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ! globalCLIContext . Quiet  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-04-10 02:39:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Check for new updates from dl.min.io.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-08-15 02:43:43 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										checkUpdate ( getMinioMode ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-17 03:21:58 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  ! globalActiveCred . IsValid ( )  &&  globalIsDistErasure  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 13:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										logger . Fatal ( config . ErrEnvCredentialsMissingDistributed ( nil ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											"Unable to initialize the server in distributed mode" ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-15 12:41:47 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Set system resources to maximum.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-04 04:18:54 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									setMaxResources ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  globalIsErasure  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-06-30 04:07:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// New global heal state
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalAllHealState  =  newHealState ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalBackgroundHealState  =  newHealState ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-06-09 13:14:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2018-01-23 06:54:55 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-03-31 02:21:19 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Configure server.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-25 15:17:52 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									handler ,  err  :=  configureServerHandler ( globalEndpoints ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-09 10:04:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-05 01:35:33 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										logger . Fatal ( config . ErrUnexpectedError ( err ) ,  "Unable to configure one of server's RPC services" ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-05-09 10:04:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-17 09:05:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-01 03:30:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									var  getCert  certs . GetCertificateFunc 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  globalTLSCerts  !=  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										getCert  =  globalTLSCerts . GetCertificate 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-05-23 12:59:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Annonying hack to ensure that Go doesn't write its own logging,
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// interleaved with our formatted logging, this allows us to
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// honor --json and --quiet flag properly.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Unfortunately we have to resort to this sort of hacky approach
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// because, Go automatically initializes ErrorLog on its own
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// and can log without application control.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									//
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// This is an implementation issue in Go and should be fixed, but
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// until then this hack is okay and works for our needs.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									pr ,  pw  :=  io . Pipe ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									go  func ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										defer  pr . Close ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										scanner  :=  bufio . NewScanner ( & contextReader { pr ,  GlobalContext } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										for  scanner . Scan ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											logger . LogIf ( GlobalContext ,  errors . New ( scanner . Text ( ) ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-07-13 01:56:57 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									httpServer  :=  xhttp . NewServer ( [ ] string { globalMinioAddr } ,  criticalErrorHandler { corsHandler ( handler ) } ,  getCert ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-05-23 12:59:18 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									httpServer . ErrorLog  =  log . New ( pw ,  "" ,  0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-19 07:19:29 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									httpServer . BaseContext  =  func ( listener  net . Listener )  context . Context  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return  GlobalContext 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-12 05:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									go  func ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-03 07:54:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										globalHTTPServerErrorCh  <-  httpServer . Start ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-12 05:59:51 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-09-14 16:11:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-12-03 07:54:26 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									globalObjLayerMutex . Lock ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalHTTPServer  =  httpServer 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalObjLayerMutex . Unlock ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  globalIsDistErasure  &&  globalEndpoints . FirstLocal ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 12:40:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										for  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											// Additionally in distributed setup, validate the setup and configuration.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-11 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											err  :=  verifyServerSystemConfig ( GlobalContext ,  globalEndpoints ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 12:40:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if  err  ==  nil  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												break 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2020-07-11 00:26:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											logger . LogIf ( GlobalContext ,  err ,  "Unable to initialize distributed setup, retrying.. after 5 seconds" ) 
							 
						 
					
						
							
								
									
										
										
										
											2020-04-02 12:40:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											select  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  <- GlobalContext . Done ( ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												return 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											case  <- time . After ( 5  *  time . Second ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-23 04:45:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-04-15 08:52:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									newObject ,  err  :=  newObjectLayer ( GlobalContext ,  globalEndpoints ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-07-02 03:22:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . SetDeploymentID ( globalDeploymentID ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-07-13 07:33:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  err  !=  nil  { 
							 
						 
					
						
							
								
									
										
										
										
											2018-06-01 03:30:15 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Stop watching for any certificate changes.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalTLSCerts . Stop ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-05-09 10:04:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										globalHTTPServer . Shutdown ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										logger . Fatal ( err ,  "Unable to initialize backend" ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-04-05 23:18:42 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Once endpoints are finalized, initialize the new object api in safe mode.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalObjLayerMutex . Lock ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalSafeMode  =  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalObjectAPI  =  newObject 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalObjLayerMutex . Unlock ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-02 06:53:16 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-01-10 18:35:06 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									newAllSubsystems ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-03-28 05:48:30 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									go  startBackgroundOps ( GlobalContext ,  newObject ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-10 10:19:03 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									logger . FatalIf ( initSafeMode ( GlobalContext ,  newObject ) ,  "Unable to initialize server switching into safe-mode" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									// Initialize users credentials and policies in background.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									go  startBackgroundIAMLoad ( GlobalContext ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 13:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  globalCacheConfig . Enabled  { 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 07:32:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// initialize the new disk cache objects.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										var  cacheAPI  CacheObjectLayer 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-23 03:16:36 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										cacheAPI ,  err  =  newServerCacheObjects ( GlobalContext ,  globalCacheConfig ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-12-05 07:32:37 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										logger . FatalIf ( err ,  "Unable to initialize disk caching" ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalObjLayerMutex . Lock ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalCacheObjectAPI  =  cacheAPI 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										globalObjLayerMutex . Unlock ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 13:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Disable safe mode operation, after all initialization is over.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalObjLayerMutex . Lock ( ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalSafeMode  =  false 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									globalObjLayerMutex . Unlock ( ) 
							 
						 
					
						
							
								
									
										
										
										
											2018-08-23 14:11:17 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-06 03:48:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// Prints the formatted startup message once object layer is initialized.
 
							 
						 
					
						
							
								
									
										
										
										
											2018-12-14 15:37:46 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									printStartupMessage ( getAPIEndpoints ( ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-10-06 03:48:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 13:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  globalActiveCred . Equal ( auth . DefaultCredentials )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										msg  :=  fmt . Sprintf ( "Detected default credentials '%s', please change the credentials immediately using 'MINIO_ACCESS_KEY' and 'MINIO_SECRET_KEY'" ,  globalActiveCred ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-10 01:27:23 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										logger . StartupMessage ( color . RedBold ( msg ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2019-10-23 13:59:13 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-07-13 07:33:21 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									handleSignals ( ) 
							 
						 
					
						
							
								
									
										
											 
										
											
												config/main: Re-write config files - add to new config v3
- New config format.
```
{
	"version": "3",
	"address": ":9000",
    "backend": {
          "type": "fs",
          "disk": "/path"
    },
	"credential": {
		"accessKey": "WLGDGYAQYIGI833EV05A",
		"secretKey": "BYvgJM101sHngl2uzjXS/OBF/aMxAN06JrJ3qJlF"
	},
	"region": "us-east-1",
	"logger": {
		"file": {
			"enable": false,
			"fileName": "",
			"level": "error"
		},
		"syslog": {
			"enable": false,
			"address": "",
			"level": "debug"
		},
		"console": {
			"enable": true,
			"level": "fatal"
		}
	}
}
```
New command lines in lieu of supporting XL.
Minio initialize filesystem backend.
~~~
$ minio init fs <path>
~~~
Minio initialize XL backend.
~~~
$ minio init xl <url1>...<url16>
~~~
For 'fs' backend it starts the server.
~~~
$ minio server
~~~
For 'xl' backend it waits for servers to join.
~~~
$ minio server
... [PROGRESS BAR] of servers connecting
~~~
Now on other servers execute 'join' and they connect.
~~~
....
minio join <url1> -- from <url2> && minio server
minio join <url1> -- from <url3> && minio server
...
...
minio join <url1> -- from <url16> && minio server
~~~
											 
										 
										
											2016-02-13 07:27:10 +08:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2017-01-17 09:05:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								// Initialize object layer with the supplied disks, objectLayer is nil upon any error.
  
						 
					
						
							
								
									
										
										
										
											2020-04-15 08:52:38 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								func  newObjectLayer ( ctx  context . Context ,  endpointZones  EndpointZones )  ( newObject  ObjectLayer ,  err  error )  {  
						 
					
						
							
								
									
										
										
										
											2017-01-17 09:05:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									// For FS only, directly use the disk.
 
							 
						 
					
						
							
								
									
										
										
										
											2020-03-25 03:43:40 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  endpointZones . NEndpoints ( )  ==  1  { 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-17 09:05:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										// Initialize new FS object layer.
 
							 
						 
					
						
							
								
									
										
										
										
											2019-11-20 09:42:27 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return  NewFSObjectLayer ( endpointZones [ 0 ] . Endpoints [ 0 ] . Path ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-17 09:05:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2020-06-13 11:04:01 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return  newErasureZones ( ctx ,  endpointZones ) 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-17 09:05:00 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}