1
mirror of https://github.com/home-assistant/core synced 2024-09-06 10:29:55 +02:00
Commit Graph

76 Commits

Author SHA1 Message Date
Fabian Affolter
1f602be80a Remove print (already covered by logger) (#2184) 2016-05-31 14:02:31 -07:00
Jan Harkes
dc8e55fb8b Don't even bother trying to kill stray child processes.
When we change our process group id we don't get keyboard interrupt
signals passed if our parent is a bash script.
2016-05-23 23:30:41 -04:00
Jan Harkes
05946ae5a2 Ignore assertions from python threading when looking for leaked threads. (#2130)
While looking for leaked resources (threads) after shutdown and before restart
we in some cases get an assertion in the python threading module where we find
a thread marked as running at the python level but it has no associated thread
at the C level.
2016-05-22 00:35:33 -04:00
Jan Harkes
53d51a467d Single process restart fixes (#2118)
* Ignore permission errors on setpgid.

When launched in a docker container we got a permission denied error
from setpgid.

* Don't fail if we find our own pidfile.

When we restart using exec we are running a new instance of home-assistant with
the same process id so we shouldn't be surprised to find an existing pidfile in
that case.

* Allow restart to work when started as python -m homeassistant.

When we are started with `python -m homeassistant`, the restart command line
becomes `python /path/to/hass/homeassistant/__main__.py`. But in that case the
python path includes `/path/to/hass/homeassistant` instead of `/path/to/hass`
and we fail on the first import.

Fix this by recognizing `/__main__.py` as part of the first argument and
injecting the proper path as PYTHONPATH environment before we start the new
home-assistant instance.
2016-05-20 11:45:16 -07:00
Jan Harkes
6b724f7da4 Not sure why, but this fixed a bad filedescriptor error. (#2116) 2016-05-20 07:03:08 -07:00
Jan Harkes
5f92ceeea9 Allow for restart without using parent/child processes. (#1793)
* Allow for restart without using parent/child processes.

Assuming that we normally correctly shut down running threads and
release resources, we just do some minimal scrubbing of open file
descriptors and child processes which would stay around across an
exec() boundary.

* Use sys.executable instead of multiprocessing.spawn.get_executable()

* Limit how many file descriptors we try to close.

Don't even try to close on OSX/Darwin until we figure out how to
recognize guarded fds because the kernel will yell at us, and kill
the process.

* Use the close on exec flag on MacOS to clean up.

* Introduce a small process runner to handle restart on windows.

* Handle missing signal.SIGHUP on Windows.
2016-05-19 23:20:59 -07:00
Per Sandström
f0f1fadee1 redirect daemon file descriptors (#2103) 2016-05-19 23:20:07 -07:00
Jan Harkes
241735c924 Change local library path from {config_dir}/lib to {config_dir}/deps. (#1799)
Just on the off chance that someone who happens to run as root and also
doesn't correctly parse "just remove config /lib and restart".
2016-04-11 20:07:50 -07:00
Paulus Schoutsen
5baa98b79f Add initial config validation 2016-03-28 23:46:12 -07:00
Paulus Schoutsen
c63a3311f4 Fix broken Python check for Python 2 2016-03-27 08:44:15 -07:00
Fabian Affolter
897b5c668f Fix PEP257 issues 2016-03-08 00:06:04 +01:00
Alexander Fortin
ac69db8133 Move hardcoded required Python version into homeassistant.const 2016-02-28 05:41:03 +01:00
Paulus Schoutsen
e80309c03c Fix imports (using isort) 2016-02-18 21:27:50 -08:00
Ian Copp
e53785f30c Fix __main__.py permissions change 2016-02-10 21:20:56 -08:00
Ian Copp
c9c15c4cf7 Fix comment phrasing
Somehow I left out the "some". Whoops.
2016-02-10 11:32:56 -08:00
Ian Copp
3046bfce7b Add small time delay to restart-osx command 2016-02-10 11:29:25 -08:00
Per Sandström
d867d26612 Merge pull request #1168 from persandstrom/sigterm_handler
fix sigterm crash
2016-02-08 19:27:26 +01:00
Per SandstrÃom
564e328698 fix sigterm crash 2016-02-08 18:09:46 +00:00
Ryan Kraus
11a2b8888b Fixes for issue #1114
1. Moved RESTART_EXIT_CODE to constants so it can safely be used by
__main__.py.
2. Allowed __main__/main to return the desired exit code.
3. Forwarded the child processes exit code to the parent process to be
duplicated.
4. Added —debug flag to pass command to force Home Assistant to run in
only one process. A warning is printed to STDERR to indicate HASS is in
debug mode. Another is printed if HASS requests a restart in debug
mode. A restart request in debug mode will quit.
5. Added an argument to __main__/main/setup_and_run_hass to indicate
that it is running in the top process. This tells it to return the exit
code rather than exiting.
2016-02-06 09:48:36 -05:00
Ryan Kraus
b56369855a Cleaned up restart handling in __main__.py
1. Fixed logged message about SIGTERM binding failure.
2. Set to only restart HASS with an exit code of 100.
3. Fixed typo in comment.
2016-01-29 22:11:11 -05:00
Ryan Kraus
519abbbfa2 Better handling of second KeyboardInterrupt
Now the second KeyboardInterrupt will be cleanly handled by the parent
process.
2016-01-26 22:41:57 -05:00
Ryan Kraus
b596fa33d6 Implemented restart service
Implemented an OS and environment safe restart service. This works by
running Home Assistant in a child process. If the child process
terminates with an exit code > 0, HASS is restarted. SIGTERM and
KeyboardInterrupts to the parent process are forwarded to the child
process. KeyboardInterrupts will only be forwarded once. The second
KeyboardInterrupt will be handled by the parent.
2016-01-26 22:39:59 -05:00
Jon Maddox
e0c1885a71 add blank line 2015-09-17 03:52:04 -04:00
Jon Maddox
d25a42426a add a way to restart on os x 2015-09-17 03:25:36 -04:00
Jon Maddox
bb172d8c98 indention 2015-09-15 02:58:13 -04:00
Jon Maddox
acb288f9e7 error handling when writing 2015-09-15 02:54:22 -04:00
Jon Maddox
c7565baa6d NOPE 2015-09-15 02:54:11 -04:00
Jon Maddox
fb29611c15 🔥 codecs 2015-09-15 02:51:23 -04:00
Jon Maddox
37cd62447e let it get overwritten 2015-09-15 02:50:15 -04:00
Jon Maddox
5cbcd72912 dupe 2015-09-15 02:48:23 -04:00
Jon Maddox
8bba0b88fd blocks! 2015-09-15 02:46:06 -04:00
Jon Maddox
3b27bef1ac DOCS 2015-09-15 02:35:20 -04:00
Jon Maddox
1fc2204ca9 get the right path 2015-09-15 02:30:19 -04:00
Jon Maddox
834ce5269d we don't actually have to do this 2015-09-15 02:30:13 -04:00
Jon Maddox
fcad068016 strip the dash 2015-09-15 02:17:01 -04:00
Jon Maddox
e12cc2fbbf attempts at dodging pep8 terror 2015-09-15 02:12:31 -04:00
Jon Maddox
9588fcc5cc install scripts 2015-09-15 02:09:02 -04:00
Andrew Thigpen
2e636f598e Add option to rotate log file daily.
Adds a command line option to rotate the log daily at midnight and
retain up to the specified amount of days.
2015-09-04 19:52:59 -05:00
Andrew Thigpen
6519e589b5 Add option to skip pip install on startup.
Since the requirements only change when the software is updated,
this adds a command line switch to disable pip installs on
startup.  The default behavior is maintained when the switch is
not specified.  Skipping pip helps a lot with startup on older RPi
hardware.
2015-09-04 16:50:57 -05:00
Ryan Kraus
7992882fa3 Cleanup PID checking logic and write PID logic. 2015-09-01 03:29:07 -04:00
Ryan Kraus
4ca8f184e6 Updated Debian daemon script. 2015-09-01 03:22:43 -04:00
Ryan Kraus
5b06e8d25e Daemon handling cleanup.
More cleanly handling whether a PID file should be checked.
Fatal Error on PID file IOError.
Pylint fix to bootstrap.
2015-09-01 02:37:52 -04:00
Ryan Kraus
ff470c8ffe Added core daemon function as flags.
Created three additional flags for the hass command:
-v -  Toggle verbose log file output
—pid-file -  Specify PID file path
—daemon -  Launch as daemon (nix only)

The core now binds to SIGQUIT on nix systems to trigger a clean
shutdown.

Modified HTTP server to write logging messages through the logging
module.
2015-09-01 02:12:00 -04:00
Paulus Schoutsen
9eefa67035 Add Python 3.4 check back 2015-08-31 08:53:59 -07:00
Paulus Schoutsen
9acf3db435 Improved console output for new users 2015-08-30 21:24:10 -07:00
Paulus Schoutsen
81466246cf Add --version command line argument 2015-08-30 00:59:27 -07:00
Paulus Schoutsen
fc6613ffb1 Fix documentation in __main__ 2015-08-29 23:35:19 -07:00
Paulus Schoutsen
a5a1f30798 Make launch more smooth 2015-08-29 23:02:07 -07:00
Ryan Kraus
bea81ddd92 Minor tweaks
Moved another import to the top of main.
Forced an exit code of 1 when there is an error initializing.
2015-08-29 23:31:33 -04:00
Ryan Kraus
f5b98c86f0 Mostly PyLint and Flake8 updates.
Rewrote imports of exceptions to be from the exceptions module.
Made nmap scanner check for libnmap dependency without crashing.
Various flake8 and pylint updates.
2015-08-29 22:34:35 -04:00