| # |
| # Licensed 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 getpass |
| |
| ephemeral_daemon_process = Process( |
| name = 'ephemeral_daemon', |
| daemon = True, |
| ephemeral = True, |
| cmdline = 'echo "ephemeral daemon started"; sleep 3600') |
| |
| main_process = Process( |
| name = 'main', |
| cmdline = 'while [[ ! -e {{stop_file}} ]]; do sleep 1; done; echo "main OK"') |
| |
| final_process = Process( |
| name = 'final', |
| final = True, |
| cmdline = 'rm {{stop_file}}; echo "final OK"') |
| |
| test_task = Task( |
| name = 'ephemeral_daemon_with_final', |
| resources = Resources(cpu=0.4, ram=32*MB, disk=64*MB), |
| processes = [ephemeral_daemon_process, main_process, final_process]) |
| |
| job = Job( |
| cluster = 'devcluster', |
| task = test_task, |
| role = getpass.getuser(), |
| environment = 'test', |
| contact = '{{role}}@localhost', |
| ) |
| |
| jobs = [ |
| job(name = 'ephemeral_daemon_with_final') |
| ] |