Skip to content
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

Unable to set numprocesses from configured environment variable #1146

Open
fgimian opened this issue Sep 14, 2020 · 0 comments
Open

Unable to set numprocesses from configured environment variable #1146

fgimian opened this issue Sep 14, 2020 · 0 comments

Comments

@fgimian
Copy link

fgimian commented Sep 14, 2020

Hello again, it doesn't appear that all environment variables defined in the config are parsed at the right time.

When using $(circus.env.<name>) for defining numprocesses, this only works when an environment variable is defined before running Circus, not when it's configured in the INI file in the [env:<name>] section. I can confirm this problem is present on the master branch of GitHub right now.

See below for an example.

(fastapi-deploy) [fots@workstation fotsies-fastapi-deploy-config]$ cat circus.ini
[watcher:app]
cmd = bash -c 'echo number is set to $number'
numprocesses = $(circus.env.number)

[env:app]
number = 8
(fastapi-deploy) [fots@workstation fotsies-fastapi-deploy-config]$ number=10 circusd circus.ini
2020-09-14 12:15:34 circus[100942] [INFO] Starting master on pid 100942
2020-09-14 12:15:34 circus[100942] [INFO] Arbiter now waiting for commands
number is set to 8
number is set to 8
number is set to 8
number is set to 8
number is set to 8
number is set to 8
number is set to 8
number is set to 8
number is set to 8
2020-09-14 12:15:34 circus[100942] [INFO] app started
number is set to 8
^C2020-09-14 12:15:34 circus[100942] [INFO] Got signal SIG_INT
2020-09-14 12:15:34 circus[100942] [INFO] Arbiter exiting
2020-09-14 12:15:34 circus[100942] [INFO] app stopped
(fastapi-deploy) [fots@workstation fotsies-fastapi-deploy-config]$ circusd circus.ini
Traceback (most recent call last):
  File "/home/fots/.virtualenv/fastapi-deploy/bin/circusd", line 11, in <module>
    load_entry_point('circus==0.16.1', 'console_scripts', 'circusd')()
  File "/home/fots/.virtualenv/fastapi-deploy/lib/python3.8/site-packages/circus/circusd.py", line 126, in main
    arbiter = Arbiter.load_from_config(args.config)
  File "/home/fots/.virtualenv/fastapi-deploy/lib/python3.8/site-packages/circus/arbiter.py", line 419, in load_from_config
    cfg = get_config(config_file)
  File "/home/fots/.virtualenv/fastapi-deploy/lib/python3.8/site-packages/circus/config.py", line 220, in get_config
    watcher['numprocesses'] = dget(section, 'numprocesses', 1,
  File "/home/fots/.virtualenv/fastapi-deploy/lib/python3.8/site-packages/circus/config.py", line 79, in dget
    value = int(value)
ValueError: invalid literal for int() with base 10: '$(circus.env.number)'

This doesn't seem to be a problem for cmd, only for numprocesses:

(fastapi-deploy) [fots@workstation fotsies-fastapi-deploy-config]$ cat circus.ini
[watcher:app]
cmd = bash -c 'echo number is set to $number'

[env:app]
number = 8
(fastapi-deploy) [fots@workstation fotsies-fastapi-deploy-config]$ circusd circus.ini
2020-09-14 12:15:57 circus[101119] [INFO] Starting master on pid 101119
2020-09-14 12:15:57 circus[101119] [INFO] Arbiter now waiting for commands
number is set to 8
2020-09-14 12:15:57 circus[101119] [INFO] app started
^C2020-09-14 12:15:58 circus[101119] [INFO] Got signal SIG_INT
2020-09-14 12:15:58 circus[101119] [INFO] Arbiter exiting
2020-09-14 12:15:58 circus[101119] [INFO] app stopped

Any help is appreciated
Fotis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant