Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
acockburn committed Jan 25, 2025
1 parent 02dfb69 commit 2cb7a6b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"request": "launch",
"module": "appdaemon",
"justMyCode": true,
"args": "-c /conf/ad_config/production --toml"
"args": "-c /conf/ad_config/production"
},
]
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"label": "Run Dev",
"command": "${command:python.interpreterPath}",
"args": ["-m", "appdaemon", "-c", "/conf/ad_config/production", "--toml"],
"args": ["-m", "appdaemon", "-c", "/conf/ad_config/production"],
"type": "shell",
"presentation":
{
Expand Down
49 changes: 34 additions & 15 deletions appdaemon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,18 @@ def handle_sig(self, signum, frame):
"""

if signum == signal.SIGUSR1:
self.AD.thread_async.call_async_no_wait(self.AD.sched.dump_schedule)
self.AD.thread_async.call_async_no_wait(self.AD.callbacks.dump_callbacks)
self.AD.thread_async.call_async_no_wait(self.AD.threading.dump_threads)
self.AD.thread_async.call_async_no_wait(self.AD.app_management.dump_objects)
self.AD.thread_async.call_async_no_wait(
self.AD.sched.dump_schedule)
self.AD.thread_async.call_async_no_wait(
self.AD.callbacks.dump_callbacks)
self.AD.thread_async.call_async_no_wait(
self.AD.threading.dump_threads)
self.AD.thread_async.call_async_no_wait(
self.AD.app_management.dump_objects)
self.AD.thread_async.call_async_no_wait(self.AD.sched.dump_sun)
if signum == signal.SIGHUP:
self.AD.thread_async.call_async_no_wait(self.AD.app_management.check_app_updates, mode=UpdateMode.TERMINATE)
self.AD.thread_async.call_async_no_wait(
self.AD.app_management.check_app_updates, mode=UpdateMode.TERMINATE)
if signum == signal.SIGINT:
self.logger.info("Keyboard interrupt")
self.stop()
Expand Down Expand Up @@ -155,7 +160,8 @@ def run(self, appdaemon: ad.AppDaemon, hadashboard, admin, aui, api, http):
self.AD.register_http(self.http_object)
else:
if http is not None:
self.logger.info("HTTP configured but no consumers are configured - disabling")
self.logger.info(
"HTTP configured but no consumers are configured - disabling")
else:
self.logger.info("HTTP is disabled")

Expand Down Expand Up @@ -206,7 +212,8 @@ def main(self): # noqa: C901
type=str,
default=None,
)
parser.add_argument("-p", "--pidfile", help="full path to PID File", default=None)
parser.add_argument("-p", "--pidfile",
help="full path to PID File", default=None)
parser.add_argument(
"-t",
"--timewarp",
Expand Down Expand Up @@ -242,9 +249,13 @@ def main(self): # noqa: C901
choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"],
)
parser.add_argument("-m", "--moduledebug", nargs=2, action="append")
parser.add_argument("-v", "--version", action="version", version="%(prog)s " + utils.__version__)
parser.add_argument("--profiledash", help=argparse.SUPPRESS, action="store_true")
parser.add_argument("--write_toml", help="use TOML for creating new app configuration files", action="store_true")
parser.add_argument("-v", "--version", action="version",
version="%(prog)s " + utils.__version__)
parser.add_argument(
"--profiledash", help=argparse.SUPPRESS, action="store_true")
parser.add_argument(
"--write_toml", help="use TOML for creating new app configuration files", action="store_true")
parser.add_argument("--toml", help="Deprecated", action="store_true")

args = parser.parse_args()

Expand Down Expand Up @@ -292,7 +303,8 @@ def main(self): # noqa: C901
try:
config = utils.read_config_file(config_file_path)
except Exception as e:
print(f"FATAL: Unexpected error loading config file: {config_file_path}")
print(f"FATAL: Unexpected error loading config file: {
config_file_path}")
print(e)
sys.exit()

Expand All @@ -307,7 +319,8 @@ def main(self): # noqa: C901
appdaemon["use_toml"] = args.write_toml
appdaemon["config_dir"] = config_dir
appdaemon["config_file"] = config_file_path
appdaemon["app_config_file"] = os.path.join(os.path.dirname(config_file_path), "apps.yaml")
appdaemon["app_config_file"] = os.path.join(
os.path.dirname(config_file_path), "apps.yaml")
appdaemon["module_debug"] = module_debug

if args.starttime is not None:
Expand Down Expand Up @@ -382,7 +395,10 @@ def main(self): # noqa: C901
self.logger = self.logging.get_logger()

if "time_zone" in config["appdaemon"]:
self.logging.set_tz(pytz.timezone(config["appdaemon"]["time_zone"]))
self.logging.set_tz(pytz.timezone(
config["appdaemon"]["time_zone"]))

commandline = ' '.join(sys.argv)

# Startup message

Expand All @@ -395,6 +411,7 @@ def main(self): # noqa: C901
sys.version_info[1],
sys.version_info[2],
)
self.logger.info(f"Commandline: {commandline}")
self.logger.info("Configuration read from: %s", config_file_path)
self.logging.dump_log_config()
self.logger.debug("AppDaemon Section: %s", config.get("appdaemon"))
Expand All @@ -421,15 +438,17 @@ def main(self): # noqa: C901
if exit is True:
sys.exit(1)

utils.check_path("config_file", self.logger, config_file_path, pathtype="file")
utils.check_path("config_file", self.logger,
config_file_path, pathtype="file")

if pidfile is not None:
self.logger.info("Using pidfile: %s", pidfile)
dir = os.path.dirname(pidfile)
name = os.path.basename(pidfile)
try:
with pid.PidFile(name, dir):
self.run(appdaemon, hadashboard, old_admin, admin, api, http)
self.run(appdaemon, hadashboard,
old_admin, admin, api, http)
except pid.PidFileError:
self.logger.error("Unable to acquire pidfile - terminating")
else:
Expand Down
3 changes: 1 addition & 2 deletions docs/APPGUIDE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ Configuration of Apps
---------------------

Apps are configured by specifying new sections in an app configuration
file. These configuration files can be written in either YAML or TOML, but must be the same type as the appdaemon configuration file, and which variant is used depends on the ``--toml`` flag
supplied to AppDaemon at startup.
file. These configuration files can be written in either YAML or TOML.

The App configuration files exist under the apps directory and can be called anything as long as they end in ``.yaml`` or ``.toml``.
You can have one single file for configuration of all apps, or break it down to have one configuration file per App, or anything in between.
Expand Down
2 changes: 1 addition & 1 deletion docs/INSTALL.rst
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ A brief description of them follows:

If no file is found in either location, AppDaemon will raise an exception. In addition, AppDaemon expects to find a dir named ``apps`` immediately subordinate to the config directory.

``-C`` name of the configuration file (default: ``appdaemon.yaml`` or ``appdaemon.toml`` depending on the value of the ``--toml`` flag)
``-C`` name of the configuration file (default: ``appdaemon.yaml`` or ``appdaemon.toml``)

.. TODO: document -d in appdaemon help text
Expand Down

0 comments on commit 2cb7a6b

Please sign in to comment.