diff options
-rwxr-xr-x | GitAutoDeploy.py | 41 | ||||
-rw-r--r-- | README.md | 18 |
2 files changed, 50 insertions, 9 deletions
diff --git a/GitAutoDeploy.py b/GitAutoDeploy.py index 12ea71a..335f630 100755 --- a/GitAutoDeploy.py +++ b/GitAutoDeploy.py @@ -742,6 +742,10 @@ class GitAutoDeploy(object): default_config_value = 'GAD_CONFIG' in os.environ and os.environ['GAD_CONFIG'] default_ssh_keygen_value = 'GAD_SSH_KEYGEN' in os.environ default_force_value = 'GAD_FORCE' in os.environ + default_config_value = 'GAD_PID_FILE' in os.environ and os.environ['GAD_PID_FILE'] + default_config_value = 'GAD_LOG_FILE' in os.environ and os.environ['GAD_LOG_FILE'] + default_config_value = 'GAD_HOST' in os.environ and os.environ['GAD_HOST'] + default_config_value = 'GAD_PORT' in os.environ and int(os.environ['GAD_PORT']) parser = argparse.ArgumentParser() @@ -756,7 +760,7 @@ class GitAutoDeploy(object): action="store_true") parser.add_argument("-c", "--config", - help="custom configuration file path", + help="custom configuration file", default=default_config_value, type=str) @@ -766,10 +770,29 @@ class GitAutoDeploy(object): action="store_true") parser.add_argument("--force", - help="attempt to kill any process that is occupying the configured port", + help="kill any process using the configured port", default=default_force_value, action="store_true") + parser.add_argument("-p", "--pid-file", + help="specify a custom pid file", + default=default_pid_file_value, + type=str) + + parser.add_argument("-l", "--log-file", + help="specify a log file", + default=default_log_file_value, + type=str) + + parser.add_argument("-h", "--host", + help="address to bind to", + default=default_host_value, + type=str) + + parser.add_argument("-p", "--port", + help="port to bind to", + default=default_port_value, + args = parser.parse_args() # Set up logging @@ -800,6 +823,20 @@ class GitAutoDeploy(object): # Read config data from json file config_data = self.read_json_file(config_file_path) + # Configuration options coming from environment or command line will + # override those coming from config file + if args.pid_file: + config_data['pidfilepath'] = args.pid_file: + + if args.log_file: + config_data['logfilepath'] = args.log_file: + + if args.host: + config_data['host'] = args.host: + + if args.port: + config_data['port'] = args.port: + # Extend config data with any repository defined by environment variables config_data = self.read_repo_config_from_environment(config_data) @@ -31,13 +31,17 @@ To start logging you can define ```"logfilepath": "/home/hermes/gitautodeploy.lo ## Command line options -Command line option | Environment variable | Description --------------------- | -------------------- | --------------------------------------------- ---daemon-mode (-d) | GAD_DAEMON_MODE | |Run in background (daemon mode) ---quiet (-q) | GAD_QUIET | Supress console output ---ssh-keygen | GAD_SSH_KEYGEN | Scan repository hosts for ssh keys ---force | GAD_FORCE | Attempt to kill any process that is occupying the configured port ---config (-c) <path> | GAD_CONFIG | Custom configuration file path +Command line option | Environment variable | Config attribute | Description +---------------------- | -------------------- | ---------------- | -------------------------- +--daemon-mode (-d) | GAD_DAEMON_MODE | | Run in background (daemon mode) +--quiet (-q) | GAD_QUIET | | Supress console output +--ssh-keygen | GAD_SSH_KEYGEN | | Scan repository hosts for ssh keys +--force | GAD_FORCE | | Kill any process using the configured port +--config (-c) <path> | GAD_CONFIG | | Custom configuration file +--pid-file (-p) <path> | GAD_PID_FILE | pidfilepath | Specify a custom pid file +--log-file (-l) <path> | GAD_LOG_FILE | logfilepath | Specify a log file +--host (-h) <host> | GAD_HOST | host | Address to bind to +--port (-p) <port> | GAD_PORT | port | Port to bind to ## Start automatically on boot |