add process names

Process name to appear in 'ps -aux'

Change-Id: I2ea69b23337d850f579ad2daf0b8b93f611a90d9
This commit is contained in:
Idan Hefetz 2018-02-20 14:50:22 +00:00
parent e3d39d61f1
commit 77df1a9545
4 changed files with 37 additions and 0 deletions

View File

@ -45,4 +45,5 @@ WebOb>=1.7.1 # MIT
eventlet!=0.18.3,!=0.20.1,<0.21.0,>=0.18.2 # MIT
six>=1.10.0 # MIT
debtcollector>=1.2.0 # Apache-2.0
cotyledon>=1.3.0 # Apache-2.0

View File

@ -11,6 +11,7 @@
# 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 setproctitle
import time
from oslo_log import log
@ -27,6 +28,19 @@ class DatasourceService(os_service.Service):
self.registered_datasources = registered_datasources
self.send_to_queue = send_to_queue_func
def name(self):
return ''
def start(self):
super(DatasourceService, self).start()
try:
setproctitle.setproctitle('{} {} {}'.format(
'vitrage-collector',
self.__class__.__name__,
self.name()))
except Exception:
LOG.warning('failed to set process name')
class SnapshotsService(DatasourceService):
def __init__(self, conf, registered_datasources, callback_function):
@ -34,6 +48,10 @@ class SnapshotsService(DatasourceService):
registered_datasources,
callback_function)
def name(self):
names = [name for name in self.registered_datasources]
return ','.join(names)
def start(self):
LOG.info("Vitrage datasources Snapshot Service - Starting...")
super(SnapshotsService, self).start()
@ -94,6 +112,10 @@ class ChangesService(DatasourceService):
callback_function)
self.changes_interval = changes_interval
def name(self):
names = [d.__class__.__name__ for d in self.registered_datasources]
return ','.join(names)
def start(self):
LOG.info("Vitrage Datasource Changes Service For: %s - Starting...",
self.registered_datasources[0].__class__.__name__)

View File

@ -12,6 +12,7 @@
# License for the specific language governing permissions and limitations
# under the License.
import abc
import setproctitle
import time
from oslo_log import log
@ -83,8 +84,18 @@ class GraphCloneWorkerBase(os_service.Service):
self._task_queue = task_queue
self._entity_graph = entity_graph
def name(self):
return ''
def start(self):
super(GraphCloneWorkerBase, self).start()
try:
setproctitle.setproctitle('{} {} {}'.format(
'vitrage-graph',
self.__class__.__name__,
self.name()))
except Exception:
LOG.warning('failed to set process name')
self._entity_graph.notifier._subscriptions = [] # Quick n dirty
self.tg.add_thread(self._read_queue)
LOG.info("%s - Started!", self.__class__.__name__)

View File

@ -74,6 +74,9 @@ class EvaluatorWorker(base.GraphCloneWorkerBase):
self._workers_num = workers_num
self._evaluator = None
def name(self):
return "(%s)" % str(self._worker_index)
def start(self):
super(EvaluatorWorker, self).start()
scenario_repo = ScenarioRepository(self._conf, self._worker_index,