-
-
Notifications
You must be signed in to change notification settings - Fork 751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding st2scheduler #4382
Merged
Adding st2scheduler #4382
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python2.7 | ||
# Licensed to the StackStorm, Inc ('StackStorm') under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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. | ||
|
||
import sys | ||
from st2actions.cmd import scheduler | ||
|
||
|
||
if __name__ == '__main__': | ||
sys.exit(scheduler.main()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
[loggers] | ||
keys=root | ||
|
||
[handlers] | ||
keys=consoleHandler, fileHandler, auditHandler | ||
|
||
[formatters] | ||
keys=simpleConsoleFormatter, verboseConsoleFormatter, gelfFormatter | ||
|
||
[logger_root] | ||
level=DEBUG | ||
handlers=consoleHandler, fileHandler, auditHandler | ||
|
||
[handler_consoleHandler] | ||
class=StreamHandler | ||
level=INFO | ||
formatter=simpleConsoleFormatter | ||
args=(sys.stdout,) | ||
|
||
[handler_fileHandler] | ||
class=st2common.log.FormatNamedFileHandler | ||
level=DEBUG | ||
formatter=verboseConsoleFormatter | ||
args=('logs/st2scheduler.log',) | ||
|
||
[handler_auditHandler] | ||
class=st2common.log.FormatNamedFileHandler | ||
level=AUDIT | ||
formatter=gelfFormatter | ||
args=('logs/st2scheduler.audit.log',) | ||
|
||
[formatter_simpleConsoleFormatter] | ||
class=st2common.logging.formatters.ConsoleLogFormatter | ||
format=%(asctime)s %(levelname)s [-] %(message)s | ||
datefmt= | ||
|
||
[formatter_verboseConsoleFormatter] | ||
class=st2common.logging.formatters.ConsoleLogFormatter | ||
format=%(asctime)s %(thread)s %(levelname)s %(module)s [-] %(message)s | ||
datefmt= | ||
|
||
[formatter_gelfFormatter] | ||
class=st2common.logging.formatters.GelfLogFormatter | ||
format=%(message)s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[loggers] | ||
keys=root | ||
|
||
[handlers] | ||
keys=syslogHandler | ||
|
||
[formatters] | ||
keys=syslogVerboseFormatter | ||
|
||
[logger_root] | ||
level=DEBUG | ||
handlers=syslogHandler | ||
|
||
[handler_syslogHandler] | ||
class=st2common.log.ConfigurableSyslogHandler | ||
level=DEBUG | ||
formatter=syslogVerboseFormatter | ||
args=() | ||
|
||
[formatter_syslogVerboseFormatter] | ||
format=st2scheduler[%(process)d]: %(levelname)s %(thread)s %(module)s [-] %(message)s | ||
datefmt= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Monkey patching should be done as early as possible. | ||
# See http://eventlet.net/doc/patching.html#monkeypatching-the-standard-library | ||
from __future__ import absolute_import | ||
from st2common.util.monkey_patch import monkey_patch | ||
monkey_patch() | ||
|
||
import os | ||
import signal | ||
import sys | ||
|
||
from st2actions.scheduler import scheduler | ||
from st2actions.scheduler import config | ||
from st2common import log as logging | ||
from st2common.service_setup import teardown as common_teardown | ||
from st2common.service_setup import setup as common_setup | ||
|
||
__all__ = [ | ||
'main' | ||
] | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
|
||
def _setup_sigterm_handler(): | ||
def sigterm_handler(signum=None, frame=None): | ||
# This will cause SystemExit to be throw and allow for component cleanup. | ||
sys.exit(0) | ||
|
||
# Register a SIGTERM signal handler which calls sys.exit which causes SystemExit to | ||
# be thrown. We catch SystemExit and handle cleanup there. | ||
signal.signal(signal.SIGTERM, sigterm_handler) | ||
|
||
|
||
def _setup(): | ||
common_setup(service='scheduler', config=config, setup_db=True, register_mq_exchanges=True, | ||
register_signal_handlers=True) | ||
_setup_sigterm_handler() | ||
|
||
|
||
def _run_scheduler(): | ||
LOG.info('(PID=%s) Scheduler started.', os.getpid()) | ||
|
||
scheduler_instance = scheduler.get_scheduler() | ||
|
||
try: | ||
scheduler_instance.start() | ||
scheduler_instance.wait() | ||
except (KeyboardInterrupt, SystemExit): | ||
LOG.info('(PID=%s) Scheduler stopped.', os.getpid()) | ||
|
||
errors = False | ||
|
||
try: | ||
scheduler_instance.shutdown() | ||
except: | ||
LOG.exception('Unable to shutdown scheduler.') | ||
errors = True | ||
|
||
if errors: | ||
return 1 | ||
except: | ||
LOG.exception('(PID=%s) Scheduler unexpectedly stopped.', os.getpid()) | ||
return 1 | ||
|
||
return 0 | ||
|
||
|
||
def _teardown(): | ||
common_teardown() | ||
|
||
|
||
def main(): | ||
try: | ||
_setup() | ||
return _run_scheduler() | ||
except SystemExit as exit_code: | ||
sys.exit(exit_code) | ||
except: | ||
LOG.exception('(PID=%s) Scheduler quit due to exception.', os.getpid()) | ||
return 1 | ||
finally: | ||
_teardown() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Licensed to the StackStorm, Inc ('StackStorm') under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You 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. | ||
|
||
from __future__ import absolute_import | ||
|
||
from oslo_config import cfg | ||
|
||
from st2common import config as common_config | ||
from st2common.constants import system as sys_constants | ||
|
||
|
||
def parse_args(args=None): | ||
cfg.CONF(args=args, version=sys_constants.VERSION_STRING) | ||
|
||
|
||
def register_opts(): | ||
_register_common_opts() | ||
_register_service_opts() | ||
|
||
|
||
def get_logging_config_path(): | ||
return cfg.CONF.scheduler.logging | ||
|
||
|
||
def _register_common_opts(): | ||
common_config.register_opts() | ||
|
||
|
||
def _register_service_opts(): | ||
scheduler_opts = [ | ||
cfg.StrOpt( | ||
'logging', | ||
default='conf/logging.scheduler.conf', | ||
help='Location of the logging configuration file.' | ||
) | ||
] | ||
|
||
cfg.CONF.register_opts(scheduler_opts, group='scheduler') | ||
|
||
|
||
register_opts() |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,6 +275,12 @@ function st2start(){ | |
--config-file $ST2_CONF | ||
done | ||
|
||
# Run the scheduler server | ||
echo 'Starting screen session st2-scheduler' | ||
screen -d -m -S st2-scheduler ./virtualenv/bin/python \ | ||
./st2actions/bin/st2scheduler \ | ||
--config-file $ST2_CONF | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You also need to add an entry for st2-scheduler under /~https://github.com/StackStorm/st2/blob/master/tools/launchdev.sh#L354. |
||
# Run the sensor container server | ||
echo 'Starting screen session st2-sensorcontainer' | ||
screen -d -m -S st2-sensorcontainer ./virtualenv/bin/python \ | ||
|
@@ -360,6 +366,8 @@ function st2start(){ | |
"st2-resultstracker" | ||
"st2-notifier" | ||
"st2-auth" | ||
"st2-timersengine" | ||
"st2-scheduler" | ||
) | ||
|
||
if [ "${include_mistral}" = true ]; then | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From https://stackstorm.slack.com/archives/C029K4CBU/p1539194738000100
One of the things we discussed in Slack if there is a chance to use safe defaults that will let the packaged service start up when respective
st2.conf
logging setting is absent.Curious if it's possible to set the default to
st2/conf/st2.package.conf
Lines 87 to 88 in 494f71f
because currently
conf/logging.scheduler.conf
can't be found if setting is set viast2.conf
.Not sure if that could break any Unit tests and which logging config path/st2.conf is used there.